Remove default bot spawns

Moved brimhaven over to listener system
This commit is contained in:
Ceikry 2021-03-19 16:34:22 -05:00
parent dc000db82b
commit 3f204cf583
7 changed files with 179 additions and 218 deletions

View file

@ -1,175 +0,0 @@
package core.game.interaction.city;
import core.cache.def.impl.ObjectDefinition;
import core.game.content.global.action.ClimbActionHandler;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.skill.gather.SkillingTool;
import core.game.node.entity.skill.agility.AgilityHandler;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.diary.DiaryType;
import core.game.node.object.GameObject;
import core.game.node.object.ObjectBuilder;
import core.game.system.task.LocationLogoutTask;
import core.game.system.task.LogoutTask;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.map.Direction;
import core.game.world.map.Location;
import core.game.world.update.flag.context.Animation;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Handles the Brimhaven dungeon.
* @author Emperor
*/
@Initializable
public final class BrimhavenDungeonPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(5084).getHandlers().put("option:leave", this);
ObjectDefinition.forId(5088).getHandlers().put("option:walk-across", this);
ObjectDefinition.forId(5090).getHandlers().put("option:walk-across", this);
ObjectDefinition.forId(5094).getHandlers().put("option:walk-up", this);
ObjectDefinition.forId(5096).getHandlers().put("option:walk-down", this);
ObjectDefinition.forId(5097).getHandlers().put("option:walk-up", this);
ObjectDefinition.forId(5098).getHandlers().put("option:walk-down", this);
ObjectDefinition.forId(5103).getHandlers().put("option:chop-down", this);
ObjectDefinition.forId(5104).getHandlers().put("option:chop-down", this);
ObjectDefinition.forId(5105).getHandlers().put("option:chop-down", this);
ObjectDefinition.forId(5106).getHandlers().put("option:chop-down", this);
ObjectDefinition.forId(5107).getHandlers().put("option:chop-down", this);
ObjectDefinition.forId(5110).getHandlers().put("option:jump-from", this);
ObjectDefinition.forId(5111).getHandlers().put("option:jump-from", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
final GameObject object = (GameObject) node;
switch (object.getId()) {
case 5084:
player.getProperties().setTeleportLocation(Location.create(2745, 3152, 0));
return true;
case 5103:
case 5104:
case 5105:
case 5106:
case 5107:
int level = 10 + ((object.getId() - 5103) * 6);
if (player.getSkills().getLevel(Skills.WOODCUTTING) < level) {
player.getPacketDispatch().sendMessage("You need a woodcutting level of " + level + " to chop down this vine.");
return true;
}
SkillingTool tool = SkillingTool.getHatchet(player);
if (tool == null) {
player.getPacketDispatch().sendMessage("You don't have an axe to cut these vines.");
return true;
}
player.animate(tool.getAnimation());
player.getPulseManager().run(new Pulse(3, player) {
@Override
public boolean pulse() {
if (ObjectBuilder.replace(object, object.transform(0), 2)) {
Location destination = getVineDestination(player, object);
player.lock(3);
player.getWalkingQueue().reset();
// Chop the vines to gain deeper access to Brimhaven Dungeon
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 14);
player.getWalkingQueue().addPath(destination.getX(), destination.getY(), true);
}
return true;
}
});
return true;
case 5110:
case 5111:
if (player.getSkills().getLevel(Skills.AGILITY) < 12) {
player.getPacketDispatch().sendMessage("You need an agility level of 12 to cross this.");
return true;
}
player.lock(12);
final Direction dir = AgilityHandler.forceWalk(player, -1, player.getLocation(), object.getLocation(), Animation.create(769), 10, 0, null).getDirection();
GameWorld.getPulser().submit(new Pulse(3, player) {
int stage = dir == Direction.NORTH ? -1 : 0;
Direction direction = dir;
@Override
public boolean pulse() {
Location l = player.getLocation();
switch (stage++) {
case 1:
direction = Direction.get(direction.toInteger() + 1 & 3);
break;
case 3:
direction = Direction.get(direction.toInteger() - 1 & 3);
break;
case 5:
if (direction == Direction.NORTH) {
return true;
}
}
if (stage == 6) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 15);
}
AgilityHandler.forceWalk(player, -1, l, l.transform(direction), Animation.create(769), 10, 0, null);
return stage == 6;
}
});
player.addExtension(LogoutTask.class, new LocationLogoutTask(13, player.getLocation()));
return true;
case 5094:
ClimbActionHandler.climb(player, null, Location.create(2643, 9594, 2));
return true;
case 5096:
ClimbActionHandler.climb(player, null, Location.create(2649, 9591, 0));
return true;
case 5097:
// Climb the stairs within Brimhaven Dungeon
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 16);
ClimbActionHandler.climb(player, null, Location.create(2636, 9510, 2));
return true;
case 5098:
ClimbActionHandler.climb(player, null, Location.create(2636, 9517, 0));
return true;
case 5088:
if (player.getSkills().getLevel(Skills.AGILITY) < 30) {
player.getPacketDispatch().sendMessage("You need an agility level of 30 to cross this.");
return true;
}
AgilityHandler.walk(player, -1, player.getLocation(), Location.create(2687, 9506, 0), Animation.create(155), 0, null);
return true;
case 5090:
if (player.getSkills().getLevel(Skills.AGILITY) < 30) {
player.getPacketDispatch().sendMessage("You need an agility level of 30 to cross this.");
return true;
}
AgilityHandler.walk(player, -1, player.getLocation(), Location.create(2682, 9506, 0), Animation.create(155), 0, null);
return true;
}
return false;
}
/**
* Gets the destination for chopping vines.
* @param player The player.
* @param object The object.
* @return The destination location.
*/
private static Location getVineDestination(Player player, GameObject object) {
if (object.getRotation() % 2 != 0) {
if (player.getLocation().getX() > object.getLocation().getX()) {
return object.getLocation().transform(-1, 0, 0);
}
return object.getLocation().transform(1, 0, 0);
}
if (player.getLocation().getY() > object.getLocation().getY()) {
return object.getLocation().transform(0, -1, 0);
}
return object.getLocation().transform(0, 1, 0);
}
}

View file

@ -1,40 +0,0 @@
/*
package core.game.interaction.city.falador
import core.game.component.Component
import core.game.component.ComponentDefinition
import core.game.component.ComponentPlugin
import core.game.node.entity.player.Player
import core.game.node.entity.player.info.PlayerDetails
import core.game.node.entity.player.link.appearance.Gender
import core.plugin.InitializablePlugin
import core.plugin.Plugin
import core.game.interaction.inter.FEMALE_HAIR_STYLES
import core.game.interaction.inter.MALE_HAIR_STYLES
const val MAKEOVER_COMPONENT_ID = 205
private const val MALE_CHILD_ID = 90
private const val FEMALE_CHILD_ID = 92
@InitializablePlugin
class MakeoverMageInterface : ComponentPlugin(){
override fun open(player: Player?, component: Component?) {
player ?: return
super.open(player, component)
player.packetDispatch.sendModelOnInterface(114,MAKEOVER_COMPONENT_ID, MALE_CHILD_ID,100)
player.packetDispatch.sendModelOnInterface(118,MAKEOVER_COMPONENT_ID, FEMALE_CHILD_ID,100)
}
override fun handle(player: Player?, component: Component?, opcode: Int, button: Int, slot: Int, itemId: Int): Boolean {
player ?: return false
player.appearance.hair.changeLook(MALE_HAIR_STYLES.random())
player.appearance.sync()
return true
}
override fun newInstance(arg: Any?): Plugin<Any> {
ComponentDefinition.put(MAKEOVER_COMPONENT_ID,this)
return this
}
}*/

View file

@ -1,4 +1,4 @@
package rs09.game.interaction.city
package rs09.game.interaction.region
import core.game.world.map.Location
import rs09.game.interaction.InteractionListener

View file

@ -1,4 +1,4 @@
package rs09.game.interaction.city
package rs09.game.interaction.region
import core.game.node.entity.impl.ForceMovement
import core.game.world.map.Direction

View file

@ -0,0 +1,77 @@
package rs09.game.interaction.region.dungeons.brimhaven
import core.game.node.entity.skill.Skills
import core.game.node.entity.skill.agility.AgilityHandler
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import org.rs09.consts.NPCs
import rs09.game.interaction.InteractionListener
class BrimhavenDungeonListeners : InteractionListener() {
val EXIT = 5084
val SANIBOCH = NPCs.SANIBOCH_1595
val VINES = intArrayOf(5103,5104,5105,5106,5107)
val STEPPING_STONES = intArrayOf(5110,5111)
val STAIRS = intArrayOf(5094,5096,5097,5098)
val LOGS = intArrayOf(5088,5090)
override fun defineListeners() {
on(EXIT,OBJECT,"leave"){player, _ ->
player.properties.teleportLocation = Location.create(2745, 3152, 0)
return@on true
}
on(STAIRS,OBJECT,"walk-up","walk-down"){player, node ->
BrimhavenUtils.handleStairs(node.asObject(),player)
return@on true
}
on(STEPPING_STONES,OBJECT,"jump-from"){player, node ->
BrimhavenUtils.handleSteppingStones(player,node.asObject())
return@on true
}
on(VINES,OBJECT,"chop-down"){player, node ->
BrimhavenUtils.handleVines(player,node.asObject())
return@on true
}
on(SANIBOCH,NPC,"pay"){player, node ->
player.dialogueInterpreter.open(SANIBOCH,node.asNpc(),10)
return@on true
}
on(LOGS,OBJECT,"walk-across"){player, node ->
if (player.skills.getLevel(Skills.AGILITY) < 30) {
player.packetDispatch.sendMessage("You need an agility level of 30 to cross this.")
return@on true
}
if(node.id == 5088){
AgilityHandler.walk(
player,
-1,
player.location,
Location.create(2687, 9506, 0),
Animation.create(155),
0.0,
null
)
} else {
AgilityHandler.walk(
player,
-1,
player.location,
Location.create(2682, 9506, 0),
Animation.create(155),
0.0,
null
)
}
return@on true
}
}
}

View file

@ -0,0 +1,99 @@
package rs09.game.interaction.region.dungeons.brimhaven
import core.game.content.global.action.ClimbActionHandler
import core.game.node.`object`.GameObject
import core.game.node.`object`.ObjectBuilder
import core.game.node.entity.player.Player
import core.game.node.entity.player.link.diary.DiaryType
import core.game.node.entity.skill.Skills
import core.game.node.entity.skill.agility.AgilityHandler
import core.game.node.entity.skill.gather.SkillingTool
import core.game.system.task.Pulse
import core.game.world.map.Direction
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import rs09.game.world.GameWorld
object BrimhavenUtils {
fun getVineDestination(player: Player, node: GameObject): Location {
if (node.rotation % 2 != 0) {
return if (player.location.x > node.location.x) {
node.location.transform(-1, 0, 0)
} else node.location.transform(1, 0, 0)
}
return if (player.location.y > node.location.y) {
node.location.transform(0, -1, 0)
} else node.location.transform(0, 1, 0)
}
fun handleStairs(node: GameObject, player: Player){
when(node.id){
5094 -> ClimbActionHandler.climb(player, null, Location.create(2643, 9594, 2))
5096 -> ClimbActionHandler.climb(player, null, Location.create(2649, 9591, 0))
5097 -> {
// Climb the stairs within Brimhaven Dungeon
player.achievementDiaryManager.finishTask(player, DiaryType.KARAMJA, 1, 16)
ClimbActionHandler.climb(player, null, Location.create(2636, 9510, 2))
}
5098 -> ClimbActionHandler.climb(player, null, Location.create(2636, 9517, 0))
}
}
fun handleSteppingStones(player: Player, node: GameObject){
if (player.skills.getLevel(Skills.AGILITY) < 12) {
player.packetDispatch.sendMessage("You need an agility level of 12 to cross this.")
return
}
player.lock(12)
val dir = AgilityHandler.forceWalk(player, -1, player.location, node.location, Animation.create(769), 10, 0.0, null).direction
val loc = player.location
player.logoutListeners["steppingstone"] = { p -> p.properties.teleportLocation = loc }
GameWorld.Pulser.submit(object : Pulse(3, player) {
var stage = if (dir == Direction.NORTH) -1 else 0
var direction = dir
override fun pulse(): Boolean {
val l = player.location
when (stage++) {
1 -> direction = Direction.get(direction.toInteger() + 1 and 3)
3 -> direction = Direction.get(direction.toInteger() - 1 and 3)
5 -> if (direction == Direction.NORTH) {
return true
}
}
if (stage == 6) {
player.achievementDiaryManager.finishTask(player, DiaryType.KARAMJA, 1, 15)
player.logoutListeners.remove("steppingstone")
}
AgilityHandler.forceWalk(player, -1, l, l.transform(direction), Animation.create(769), 10, 0.0, null)
return stage == 6
}
})
}
fun handleVines(player: Player, node: GameObject){
val level: Int = 10 + (node.id - 5103) * 6
if (player.skills.getLevel(Skills.WOODCUTTING) < level) {
player.packetDispatch.sendMessage("You need a woodcutting level of $level to chop down this vine.")
return
}
val tool = SkillingTool.getHatchet(player)
if (tool == null) {
player.packetDispatch.sendMessage("You don't have an axe to cut these vines.")
return
}
player.animate(tool.animation)
player.pulseManager.run(object : Pulse(3, player) {
override fun pulse(): Boolean {
if (ObjectBuilder.replace(node.asObject(), node.asObject().transform(0), 2)) {
val destination = getVineDestination(player,node.asObject())
player.lock(3)
player.walkingQueue.reset()
// Chop the vines to gain deeper access to Brimhaven Dungeon
player.achievementDiaryManager.finishTask(player, DiaryType.KARAMJA, 1, 14)
player.walkingQueue.addPath(destination.x, destination.y, true)
}
return true
}
})
}
}

View file

@ -16,7 +16,7 @@
"enable_bots": true,
"autostock_ge": true,
"allow_token_purchase": true,
"max_adv_bots": "100",
"max_adv_bots": "0",
"message_of_the_week_identifier": "0",
"message_of_the_week_text": "Welcome to 2009Scape! <br><col=11ff00>N</col><col=ecff00>o</col><col=ff8300>w</col <col=ff0000>i</col><col=ff00d4>n</col> <col=6100ff>T</col><col=000fff>e</col><col=00f0ff>c</col><col=00ff59>h</col><col=93ff00>n</col><col=ff9e00>i</col><col=ff0000>c</col><col=ff00d1>o</col><col=2700ff>l</col><col=00f7ff>o</col><col=00ff0c>r</col><col=ff0000>!</col>"
},