Rebase with upstream

This commit is contained in:
verinia 2019-05-28 22:15:17 -08:00
commit 101b8314c9
2889 changed files with 481914 additions and 0 deletions

View file

@ -0,0 +1,424 @@
package plugin.skill.agility;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.cache.def.impl.NPCDefinition;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.global.action.ClimbActionHandler;
import org.crandor.game.content.global.action.DoorActionHandler;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.agility.AgilityCourse;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.combat.ImpactHandler.HitsplatType;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.BarcrawlManager;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.game.world.update.flag.context.Graphics;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.PluginManager;
/**
* Handles the barbarian outpost course.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class BarbarianOutpostCourse extends AgilityCourse {
/**
* The rope delay.
*/
private static int ropeDelay;
/**
* Constructs a new {@code BarbarianOutpostCourse} {@code Object}.
*/
public BarbarianOutpostCourse() {
this(null);
}
/**
* Constructs a new {@code BarbarianOutpostCourse} {@code Object}.
* @param player the player.
*/
public BarbarianOutpostCourse(Player player) {
super(player, 6, 46.2);
}
@Override
public AgilityCourse createInstance(Player player) {
return new BarbarianOutpostCourse(player);
}
@Override
public boolean handle(final Player player, final Node node, final String option) {
final int id = node.getId();
getCourse(player);
switch (id) {
case 2115:
case 2116:
if (!player.getBarcrawlManager().isFinished() || player.getBarcrawlManager().isStarted()) {
player.getDialogueInterpreter().open(384);
} else {
DoorActionHandler.handleAutowalkDoor(player, (GameObject) node);
}
break;
case 20210:
handlePipe(player, (GameObject) node);
break;
case 2282:
handleRopeSwing(player, (GameObject) node);
break;
case 2294:
handleLogBalance(player, (GameObject) node);
break;
case 2302:
handleLedgeBalance(player, (GameObject) node);
break;
case 20211:
if (player.getLocation().getX() < node.getLocation().getX()) {
return true;
}
AgilityHandler.climb(player, 2, ClimbActionHandler.CLIMB_UP, player.getLocation().transform(-1, 0, 1), 8, "You climb the netting...");
break;
case 1948:
if (player.getLocation().getX() > node.getLocation().getX()) {
player.getPacketDispatch().sendMessage("You cannot climb from this side.");
break;
}
final int flag = node.getLocation().equals(new Location(2536, 3553, 0)) ? 4 : node.getLocation().equals(new Location(2539, 3553, 0)) ? 5 : 6;
player.getPacketDispatch().sendMessage("You climb the low wall...");
AgilityHandler.forceWalk(player, flag, node.getLocation().transform(-1, 0, 0), node.getLocation().transform(1, 0, 0), Animation.create(839), 10, 13.5, null);
break;
case 455:
player.getBarcrawlManager().read();
break;
case 385:
player.getPacketDispatch().sendMessage("The scorpion stings you!");
player.getImpactHandler().manualHit(player, 3, HitsplatType.NORMAL);
break;
}
return true;
}
/**
* Handles the squeezing through of a pipe.
* @param player the player.
* @param object the object.
*/
private void handlePipe(final Player player, final GameObject object) {
if (player.getSkills().getStaticLevel(Skills.AGILITY) < 35) {
player.getDialogueInterpreter().sendDialogue("You need an Agility level of at least 35 to enter.");
return;
}
AgilityHandler.forceWalk(player, 0, player.getLocation(), player.getLocation().transform(0, getPipeTransform(player), 0), Animation.create(746), 25, 22, null, 1);
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
player.faceLocation(object.getLocation());
return true;
}
});
}
/**
* Handles the rope swing obstacle.
* @param player the player.
* @param object the object.
*/
private void handleRopeSwing(final Player player, final GameObject object) {
if (player.getLocation().getY() < 3554) {
player.getPacketDispatch().sendMessage("You cannot do that from here.");
return;
}
if (ropeDelay > GameWorld.getTicks()) {
player.getPacketDispatch().sendMessage("The rope is being used.");
return;
}
if (AgilityHandler.hasFailed(player, 1, 0.1)) {
AgilityHandler.fail(player, 0, Location.create(2549, 9951, 0), null, getHitAmount(player), "You slip and fall to the pit bellow.");
return;
}
ropeDelay = GameWorld.getTicks() + 2;
player.getPacketDispatch().sendObjectAnimation(object, Animation.create(497), true);
AgilityHandler.forceWalk(player, 0, player.getLocation(), Location.create(2551, 3549, 0), Animation.create(751), 50, 22, "You skillfully swing across.", 1);
}
/**
* Handles the log balance obstacle.
* @param player the player.
* @param object the object.
*/
private void handleLogBalance(final Player player, final GameObject object) {
final boolean failed = AgilityHandler.hasFailed(player, 1, 0.5);
final Location end = failed ? Location.create(2545, 3546, 0) : Location.create(2541, 3546, 0);
player.getPacketDispatch().sendMessage("You walk carefully across the slippery log...");
AgilityHandler.walk(player, failed ? -1 : 1, Location.create(2551, 3546, 0), end, Animation.create(155), failed ? 0.0 : 13.5, failed ? null : "...You make it safely to the other side.");
if (failed) {
AgilityHandler.walk(player, -1, player.getLocation(), Location.create(2545, 3546, 0), Animation.create(155), 0.0, null);
GameWorld.submit(getSwimPulse(player));
return;
}
}
/**
* Handles the ledge balance obstacle.
* @param player the player.
* @param object the object.
*/
private void handleLedgeBalance(final Player player, final GameObject object) {
final boolean failed = AgilityHandler.hasFailed(player, 1, 0.3);
final Location end = failed ? Location.create(2534, 3547, 1) : Location.create(2532, 3547, 1);
AgilityHandler.walk(player, failed ? -1 : 3, Location.create(2536, 3547, 1), end, Animation.create(157), failed ? 0.0 : 22, failed ? null : "You skillfully edge across the gap.");
player.getPacketDispatch().sendMessage("You put your foot on the ledge and try to edge across..");
if (failed) {
AgilityHandler.fail(player, 3, Location.create(2534, 3545, 0), new Animation(760), getHitAmount(player), "You slip and fall to the pit bellow.");
return;
}
}
/**
* Gets the pulse used to swim when failing the log balance.
* @param player the player.
* @return {@code Pulse} the pulse.
*/
private Pulse getSwimPulse(final Player player) {
return new Pulse(1, player) {
int counter;
@Override
public boolean pulse() {
switch (++counter) {
case 6:
player.animate(Animation.create(771));
player.getPacketDispatch().sendMessages("...You loose your footing and fall into the water.", "Something in the water bites you.");
break;
case 7:
player.graphics(Graphics.create(68));
player.getProperties().setTeleportLocation(Location.create(2545, 3545, 0));
player.getImpactHandler().manualHit(player, getHitAmount(player), HitsplatType.NORMAL);
AgilityHandler.walk(player, -1, Location.create(2545, 3545, 0), Location.create(2545, 3543, 0), Animation.create(752), 0.0, null);
break;
case 11:
player.getProperties().setTeleportLocation(Location.create(2545, 3542, 0));
return true;
}
return false;
}
};
}
/**
* Gets the pipe transformation.
* @param player the player.
* @return the transform.
*/
private int getPipeTransform(final Player player) {
return (player.getLocation().getY() > 3558 ? -3 : 3);
}
@Override
public void configure() {
ObjectDefinition.forId(2115).getConfigurations().put("option:open", this);
ObjectDefinition.forId(2116).getConfigurations().put("option:open", this);
ObjectDefinition.forId(20210).getConfigurations().put("option:squeeze-through", this);
ObjectDefinition.forId(2282).getConfigurations().put("option:swing-on", this);
ObjectDefinition.forId(2294).getConfigurations().put("option:walk-across", this);
ObjectDefinition.forId(20211).getConfigurations().put("option:climb-over", this);
ObjectDefinition.forId(2302).getConfigurations().put("option:walk-across", this);
ObjectDefinition.forId(1948).getConfigurations().put("option:climb-over", this);
ItemDefinition.forId(455).getConfigurations().put("option:read", this);
NPCDefinition.forId(385).getConfigurations().put("option:pick-up", this);
PluginManager.definePlugin(new BarbarianGuardDialogue());
}
@Override
public Location getDestination(Node node, Node n) {
if (n instanceof GameObject) {
switch (n.getId()) {
case 2282:// rope.
return Location.create(2551, 3554, 0);
case 20210:
return node.getLocation().getY() > n.getLocation().getY() ? Location.create(2552, 3561, 0) : Location.create(2552, 3558, 0);
}
}
return null;
}
/**
* The barbarian guard dialogue plugin.
* @author 'Vexia
* @version 1.0
*/
public static final class BarbarianGuardDialogue extends DialoguePlugin {
/**
* Constructs a new {@code BarbarianGuardDialogue} {@code Object}.
*/
public BarbarianGuardDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code BarbarianGuardDialogue} {@code Object}.
* @param player the player.
*/
public BarbarianGuardDialogue(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new BarbarianGuardDialogue(player);
}
@Override
public boolean open(Object... args) {
if (!player.getBarcrawlManager().isStarted()) {
npc("O, waddya want?");
} else if (player.getBarcrawlManager().isFinished() && !player.getBarcrawlManager().isStarted()) {
npc("'Ello friend.");
stage = 50;
} else {
npc("So, how's the Barcrawl coming along?");
stage = 20;
}
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
options("I want to come through this gate.", "I want some money.");
stage++;
break;
case 1:
switch (buttonId) {
case 1:
player("I want to come throught his gate.");
stage = 5;
break;
case 2:
player("I want some money.");
stage = 3;
break;
}
break;
case 3:
npc("Do I look like a bank to you?");
stage++;
break;
case 4:
end();
break;
case 5:
if (player.getBarcrawlManager().isFinished()) {
npc("You may pass if you like. You are a true", "barbarian now.");
stage = 4;
} else {
npc("Barbarians only. Are you a barbarian? You don't look", "like one.");
stage++;
}
break;
case 6:
options("Hmm, yep you've got me there.", "Looks can be deceiving, I am in fact a barbarian.");
stage++;
break;
case 7:
switch (buttonId) {
case 1:
player("Hmm, yep you've got me there.");
stage = 4;
break;
case 2:
player("Looks can be deceiving, I am in fact a barbarian.");
stage++;
break;
}
break;
case 8:
npc("If you're a barbarian you need to be able to drink like", "one. We barbarians like a good drink.");
stage++;
break;
case 9:
npc("I have the perfect challenge for you... the Alfred", "Grimhand Barcrawl! First completed by Alfred", "Grimhand.");
stage++;
break;
case 10:
player.getBarcrawlManager().reset();
player.getBarcrawlManager().setStarted(true);
player.getInventory().add(BarcrawlManager.BARCRAWL_CARD, player);
interpreter.sendDialogue("The guard hands you a Barcrawl card.");
stage++;
break;
case 11:
npc("Take that card to each of the bards named on it. The", "bartenders will know what it means. We're kinda well", "known.");
stage++;
break;
case 12:
npc("They'll give you their strongest drink and sign your", "card. When you've done all that, we'll be happy to let", "you in.");
stage++;
break;
case 13:
end();
break;
case 20:
if (!player.getBarcrawlManager().hasCard()) {
player("I've lost my barcrawl card...");
stage = 23;
} else if (player.getBarcrawlManager().isFinished()) {
player("I tink I jusht 'bout done dem all... but I losht count...");
stage = 24;
} else {
player("I haven't finished it yet.");
stage++;
}
break;
case 21:
npc("Well come back when you have, you lightweight.");
stage++;
break;
case 22:
end();
break;
case 23:
npc("What are you like? You're gonna have to start all over", "now.");
stage = 10;
break;
case 24:
if (!player.getInventory().containsItem(BarcrawlManager.BARCRAWL_CARD)) {
end();
break;
}
player.getBarcrawlManager().setStarted(false);
player.getBank().remove(BarcrawlManager.BARCRAWL_CARD);
player.getInventory().remove(BarcrawlManager.BARCRAWL_CARD);
interpreter.sendDialogue("You give the card to the barbarian.");
stage++;
break;
case 25:
npc("Yep that seems fine, you can come in now. I never", "learned to read, but you look like you've drunk plenty.");
stage = 22;
break;
case 50:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 384 };
}
}
}

View file

@ -0,0 +1,162 @@
package plugin.skill.agility;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.skill.member.agility.AgilityCourse;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles the gnome stronghold agility course.
* @author Emperor
*/
@InitializablePlugin
public final class GnomeStrongholdCourse extends AgilityCourse {
/**
* The pipes currently in usage.
*/
private static final int[] USED_PIPES = new int[2];
/**
* The trainer NPCs.
*/
private static final NPC[] TRAINERS = new NPC[5];
/**
* Constructs a new {@code GnomeStrongholdCourse} {@code Object}.
*/
public GnomeStrongholdCourse() {
this(null);
}
/**
* Constructs a new {@code GnomeStrongholdCourse} {@code Object}.
* @param player The player.
*/
public GnomeStrongholdCourse(Player player) {
super(player, 5, 39.0);
}
@Override
public boolean handle(final Player player, Node node, String option) {
getCourse(player); // Sets the extension.
GameObject object = (GameObject) node;
switch (object.getId()) {
case 2295:
TRAINERS[0].sendChat("Okay get over that log, quick quick!");
player.getPacketDispatch().sendMessage("You walk carefully across the slippery log...");
AgilityHandler.walk(player, 0, Location.create(2474, 3436, 0), Location.create(2474, 3429, 0), Animation.create(155), 7.5, "...You make it safely to the other side.");
return true;
case 2285:
TRAINERS[1].sendChat("Move it, move it, move it!");
player.getPacketDispatch().sendMessage("You climb the netting...");
AgilityHandler.climb(player, 1, Animation.create(828), object.getLocation().transform(0, -1, 1), 7.5, null);
return true;
case 35970:
TRAINERS[2].sendChat("That's it - straight up.");
player.getPacketDispatch().sendMessage("You climb the tree..");
AgilityHandler.climb(player, 2, Animation.create(828), Location.create(2473, 3420, 2), 5.0, "...To the platform above.");
return true;
case 2312:
TRAINERS[3].sendChat("Come on scaredy cat, get across that rope!");
player.getPacketDispatch().sendMessage("You carefully cross the tightrope.");
AgilityHandler.walk(player, 3, Location.create(2477, 3420, 2), Location.create(2483, 3420, 2), Animation.create(155), 7.5, null);
return true;
case 4059:
player.getPacketDispatch().sendMessage("You can't do that from here.");
return true;
case 2314:
case 2315:
player.getPacketDispatch().sendMessage("You climb down the tree..");
AgilityHandler.climb(player, 4, Animation.create(828), Location.create(2487, 3420, 0), 5.0, "You land on the ground.");
return true;
case 2286:
TRAINERS[4].sendChat("My Granny can move faster than you.");
player.faceLocation(player.getLocation().transform(0, 2, 0));
player.getPacketDispatch().sendMessage("You climb the netting...");
AgilityHandler.climb(player, 5, Animation.create(828), player.getLocation().transform(0, 2, 0), 7.5, null);
return true;
case 154:
case 4058:
if (object.getLocation().getY() == 3435) {
player.getPacketDispatch().sendMessage("You can't do that from here.");
return true;
}
final int index = object.getId() == 154 ? 0 : 1;
if (USED_PIPES[index] > GameWorld.getTicks()) {
player.getPacketDispatch().sendMessage("The pipe is being used.");
return true;
}
USED_PIPES[index] = GameWorld.getTicks() + 10;
final int x = 2484 + (index * 3);
player.lock(12);
AgilityHandler.forceWalk(player, -1, Location.create(x, 3430, 0), Location.create(x, 3433, 0), Animation.create(749), 10, 0, null);
AgilityHandler.forceWalk(player, -1, Location.create(x, 3433, 0), Location.create(x, 3435, 0), Animation.create(844), 10, 0, null, 5);
AgilityHandler.forceWalk(player, 6, Location.create(x, 3435, 0), Location.create(x, 3437, 0), Animation.create(748), 20, 7.5, null, 8);
player.addExtension(LogoutTask.class, new LocationLogoutTask(12, Location.create(x, 3430, 0)));
return true;
}
return false;
}
@Override
public Location getDestination(Node node, Node n) {
GameObject object = (GameObject) n;
switch (object.getId()) {
case 2295:
return Location.create(2474, 3436, 0);
case 2286:
int x = node.getLocation().getX();
if (x < n.getLocation().getX()) {
x = n.getLocation().getX();
} else if (x > n.getLocation().getX() + 1) {
x = n.getLocation().getX() + 1;
}
return Location.create(x, n.getLocation().getY() - 1, 0);
case 154:
case 4058:
if (n.getLocation().getY() == 3431) {
return n.getLocation().transform(0, -1, 0);
}
}
return null;
}
@Override
public void configure() {
TRAINERS[0] = NPC.create(162, Location.create(2473, 3438, 0));
TRAINERS[1] = NPC.create(162, Location.create(2478, 3426, 0));
TRAINERS[2] = NPC.create(162, Location.create(2474, 3422, 1));
TRAINERS[3] = NPC.create(162, Location.create(2472, 3419, 2));
TRAINERS[4] = NPC.create(162, Location.create(2489, 3425, 0));
for (NPC npc : TRAINERS) {
npc.init();
npc.setWalkRadius(3);
}
ObjectDefinition.forId(2295).getConfigurations().put("option:walk-across", this);
ObjectDefinition.forId(2285).getConfigurations().put("option:climb-over", this);
ObjectDefinition.forId(35970).getConfigurations().put("option:climb", this);
ObjectDefinition.forId(2312).getConfigurations().put("option:walk-on", this);
ObjectDefinition.forId(4059).getConfigurations().put("option:walk-on", this);
ObjectDefinition.forId(2314).getConfigurations().put("option:climb-down", this);
ObjectDefinition.forId(2315).getConfigurations().put("option:climb-down", this);
ObjectDefinition.forId(2286).getConfigurations().put("option:climb-over", this);
ObjectDefinition.forId(154).getConfigurations().put("option:squeeze-through", this);
ObjectDefinition.forId(4058).getConfigurations().put("option:squeeze-through", this);
}
@Override
public AgilityCourse createInstance(Player player) {
return new GnomeStrongholdCourse(player);
}
}

View file

@ -0,0 +1,282 @@
package plugin.skill.agility;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.DoorActionHandler;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.agility.AgilityCourse;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles the wilderness agility course.
* @author 'Vexia
*/
@InitializablePlugin
public final class WildernessCourse extends AgilityCourse {
/**
* The rope delay.
*/
private static int ropeDelay;
/**
* Constructs a new {@code WildernessCourse} {@code Object}.
*/
public WildernessCourse() {
this(null);
}
/**
* Constructs a new {@code WildernessCourse} {@code Object}.
* @param player the player.
*/
public WildernessCourse(Player player) {
super(player, 5, 499);
}
@Override
public boolean handle(final Player player, Node node, String option) {
getCourse(player); // Sets the extension.
GameObject object = (GameObject) node;
switch (object.getId()) {
case 2309:
handleEntrance(player, object);
break;
case 2307:
case 2308:
DoorActionHandler.handleAutowalkDoor(player, object);
handleEntranceObstacle(player, object);
break;
case 2288:
handlePipe(player, object);
break;
case 2283:
handleRopeSwing(player, object);
break;
case 2311:
handleSteppingStones(player, object);
break;
case 2297:
handleLogBalance(player, object);
break;
case 2328:
handleRockClimb(player, object);
break;
}
return true;
}
/**
* Handles the door entrance.
* @param player the player.
* @param object the object.
*/
private void handleEntrance(final Player player, final GameObject object) {
if (player.getLocation().getY() > 3916 || player.getSkills().getLevel(Skills.AGILITY) >= 52) {
DoorActionHandler.handleAutowalkDoor(player, object);
if (player.getLocation().getY() <= 3916) {
handleEntranceObstacle(player, object);
}
} else {
player.getDialogueInterpreter().sendDialogue("You need an Agility level of at least 52 to enter.");
}
}
/**
* Handles the entrance obstacle.
* @param player the player.
* @param object the object.
*/
private void handleEntranceObstacle(final Player player, final GameObject object) {
GameWorld.submit(new Pulse(1, player) {
int counter;
final boolean fail = AgilityHandler.hasFailed(player, 1, 0.3);
@Override
public boolean pulse() {
switch (++counter) {
case 2:
final Location end = fail ? Location.create(2998, 3924, 0) : object.getId() < 2309 ? Location.create(2998, 3917, 0) : Location.create(2998, 3930, 0);
final Location start = object.getId() < 2309 ? player.getLocation() : Location.create(2998, 3917, 0);
player.getPacketDispatch().sendMessage("You go through the gate and try to edge over the ridge...");
AgilityHandler.walk(player, -1, start, end, Animation.create(155), fail ? 0.0 : 15.00, fail ? "You loose your footing and fail into the wolf pit." : "You skillfully balance across the ridge...");
break;
case 9:
if (fail) {
AgilityHandler.fail(player, 0, player.getLocation().transform(object.getId() < 2309 ? -2 : 2, 0, 0), Animation.create(object.getId() < 2309 ? 771 : 771), getHitAmount(player), null);
}
return fail;
case 15:
player.lock(3);
break;
case 16:
Location doorLoc = object.getId() < 2309 ? new Location(2998, 3917, 0) : new Location(2998, 3931, 0);
DoorActionHandler.handleAutowalkDoor(player, RegionManager.getObject(doorLoc));
return true;
}
return false;
}
});
}
/**
* Handles the pipe obstacle.
* @param player the pipe.
* @param object the object.
*/
private void handlePipe(final Player player, final GameObject object) {
if (object.getLocation().getY() == 3948) {
player.getPacketDispatch().sendMessage("You can't do that from here.");
return;
}
if (player.getSkills().getLevel(Skills.AGILITY) < 49) {
player.getDialogueInterpreter().sendDialogue("You need an Agility level of at least 49 to do this.");
return;
}
player.lock(12);
GameWorld.submit(new Pulse(1, player) {
@Override
public boolean pulse() {
int x = 3004;
AgilityHandler.forceWalk(player, -1, Location.create(x, 3937, 0), Location.create(x, 3939, 0), Animation.create(749), 10, 0, null);
AgilityHandler.forceWalk(player, -1, Location.create(x, 3939, 0), Location.create(x, 3948, 0), Animation.create(844), 10, 0, null, 1);
AgilityHandler.forceWalk(player, 0, Location.create(x, 3948, 0), Location.create(x, 3950, 0), Animation.create(748), 20, 12.5, null, 14);
player.addExtension(LogoutTask.class, new LocationLogoutTask(14, Location.create(3004, 3937, 0)));
return true;
}
});
}
/**
* Handles the rope swing obstacle.
* @param player the player.
* @param object the object.
*/
private void handleRopeSwing(final Player player, final GameObject object) {
if (player.getLocation().getY() < 3554) {
player.getPacketDispatch().sendMessage("You cannot do that from here.");
return;
}
if (ropeDelay > GameWorld.getTicks()) {
player.getPacketDispatch().sendMessage("The rope is being used.");
return;
}
if (AgilityHandler.hasFailed(player, 1, 0.1)) {
AgilityHandler.fail(player, 0, Location.create(3005, 10357, 0), null, getHitAmount(player), "You slip and fall to the pit bellow.");
return;
}
ropeDelay = GameWorld.getTicks() + 2;
player.getPacketDispatch().sendObjectAnimation(object, Animation.create(497), true);
AgilityHandler.forceWalk(player, 1, player.getLocation(), Location.create(3005, 3958, 0), Animation.create(751), 50, 20, "You skillfully swing across.", 1);
}
/**
* Handles the stepping stone obstacle.
* @param player the player.
* @param object the object.
*/
private void handleSteppingStones(final Player player, final GameObject object) {
final boolean fail = AgilityHandler.hasFailed(player, 1, 0.3);
player.addExtension(LogoutTask.class, new LocationLogoutTask(12, player.getLocation()));
GameWorld.submit(new Pulse(2, player) {
int counter;
@Override
public boolean pulse() {
if (counter == 3 && fail) {
AgilityHandler.fail(player, -1, Location.create(3001, 3963, 0), Animation.create(771), (int) (player.getSkills().getLifepoints() * 0.26), "...You lose your footing and fall into the lava.");
return true;
}
AgilityHandler.forceWalk(player, counter == 5 ? 2 : -1, player.getLocation(), player.getLocation().transform(-1, 0, 0), Animation.create(741), 10, counter == 5 ? 20 : 0, counter != 0 ? null : "You carefully start crossing the stepping stones...");
return ++counter == 6;
}
@Override
public void stop() {
super.stop();
}
});
}
/**
* Handles the log balance obstacle.
* @param player the player.
* @param object the object.
*/
private void handleLogBalance(final Player player, final GameObject object) {
final boolean failed = AgilityHandler.hasFailed(player, 1, 0.5);
final Location end = failed ? Location.create(2998, 3945, 0) : Location.create(2994, 3945, 0);
player.getPacketDispatch().sendMessage("You walk carefully across the slippery log...");
AgilityHandler.walk(player, failed ? -1 : 3, player.getLocation(), end, Animation.create(155), failed ? 0.0 : 20, failed ? null : "You skillfully edge across the gap.");
if (failed) {
GameWorld.submit(new Pulse(5, player) {
@Override
public boolean pulse() {
player.faceLocation(Location.create(2998, 3944, 0));
AgilityHandler.fail(player, 3, Location.create(2998, 10345, 0), Animation.create(770), getHitAmount(player), "You slip and fall onto the spikes below.");
return true;
}
});
return;
}
}
/**
* Handles the rock climbing obstacle.
* @param player the player.
* @param object the object.
*/
private void handleRockClimb(final Player player, final GameObject object) {
AgilityHandler.walk(player, 4, player.getLocation(), player.getLocation().transform(0, -4, 0), Animation.create(740), 0, "You reach the top.");
GameWorld.submit(new Pulse(4, player) {
@Override
public boolean pulse() {
player.getAnimator().reset();
return true;
}
});
}
@Override
public Location getDestination(Node node, Node n) {
switch (n.getId()) {
case 2283:
return Location.create(3005, 3953, 0);
case 2311:
return Location.create(3002, 3960, 0);
case 2297:
return Location.create(3002, 3945, 0);
case 2328:
return n.getLocation().transform(0, 1, 0);
}
return null;
}
@Override
public void configure() {
ObjectDefinition.forId(2309).getConfigurations().put("option:open", this);
ObjectDefinition.forId(2308).getConfigurations().put("option:open", this);
ObjectDefinition.forId(2307).getConfigurations().put("option:open", this);
ObjectDefinition.forId(2288).getConfigurations().put("option:squeeze-through", this);
ObjectDefinition.forId(2283).getConfigurations().put("option:swing-on", this);
ObjectDefinition.forId(2311).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(2297).getConfigurations().put("option:walk-across", this);
ObjectDefinition.forId(2328).getConfigurations().put("option:climb", this);
}
@Override
public AgilityCourse createInstance(Player player) {
return new WildernessCourse(player);
}
}

View file

@ -0,0 +1,50 @@
package plugin.skill.agility.brimhaven;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.system.task.MovementHook;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
/**
* Handles the blade trap.
* @author Emperor
*/
public final class BladeTrap implements MovementHook {
@Override
public boolean handle(Entity e, final Location l) {
if (BrimhavenArena.sawBladeActive) {
final Direction dir = e.getDirection();
final Player player = (Player) e;
final Location start = l.transform(-dir.getStepX(), -dir.getStepY(), 0);
e.lock(5);
e.addExtension(LogoutTask.class, new LocationLogoutTask(5, start));
GameWorld.submit(new Pulse(2, e) {
@Override
public boolean pulse() {
Direction direction = dir;
Direction d = Direction.get(direction.toInteger() + 2 & 3);
if (RegionManager.getObject(player.getLocation().transform(dir)) != null) {
Direction s = d;
d = direction;
direction = s;
}
Location loc = player.getLocation();
AgilityHandler.failWalk(player, 1, loc, loc.transform(direction), loc.transform(direction), Animation.create(846), 10, 3, "You were hit by the saw blade!").setDirection(d);
return true;
}
});
return false;
}
return true;
}
}

View file

@ -0,0 +1,330 @@
package plugin.skill.agility.brimhaven;
import org.crandor.game.component.Component;
import org.crandor.game.content.global.action.ClimbActionHandler;
import org.crandor.game.interaction.Option;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.HintIconManager;
import org.crandor.game.node.entity.player.link.diary.DiaryType;
import org.crandor.game.node.item.GroundItem;
import org.crandor.game.node.item.GroundItemManager;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.node.object.ObjectBuilder;
import org.crandor.game.system.task.MovementHook;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.*;
import org.crandor.game.world.map.zone.MapZone;
import org.crandor.game.world.map.zone.ZoneBuilder;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.tools.RandomFunction;
import java.util.HashMap;
import java.util.Map;
/**
* Handles the Brimhaven agility arena zone.
* @author Emperor
*/
@InitializablePlugin
public final class BrimhavenArena extends MapZone implements Plugin<Object> {
/**
* 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 ticket dispenser locations.
*/
private static final Location[] DISPENSERS = new Location[24];
/**
* The agility ticket reward item.
*/
private static final Item TICKET = new Item(2996);
/**
* 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);
}
/**
* 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);
player.getConfigManager().set(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 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 GameObject) {
GameObject object = (GameObject) 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);
player.getConfigManager().set(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));
}
if (!player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).isComplete(1, 0)) {
player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).updateTask(player, 1, 0, true);
}
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 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);
}
}
GameWorld.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) {
GameObject object = RegionManager.getObject(3, 2788, 9579);
ObjectBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
object = RegionManager.getObject(3, 2789, 9579);
ObjectBuilder.replace(object, object.transform(0), ticks);
object = RegionManager.getObject(3, 2783, 9551);
ObjectBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
object = RegionManager.getObject(3, 2783, 9552);
ObjectBuilder.replace(object, object.transform(0), ticks);
object = RegionManager.getObject(3, 2761, 9584);
ObjectBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
object = RegionManager.getObject(3, 2761, 9585);
ObjectBuilder.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++) {
GameObject object = RegionManager.getObject(l.transform(x, 0, 0));
ObjectBuilder.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) });
/**
* 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 exit location of the plank.
*/
Location[] exit;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ZoneBuilder.configure(this);
return this;
}
@Override
public Object fireEvent(String identifier, Object... args) {
return null;
}
}

View file

@ -0,0 +1,408 @@
package plugin.skill.agility.brimhaven;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* The brimhaven course handling plugin.
* @author Emperor
*/
@InitializablePlugin
public final class BrimhavenCourse extends OptionHandler {
@Override
public boolean handle(final Player player, Node node, String option) {
final GameObject object = (GameObject) node;
Direction dir = object.getDirection();
Location start = player.getLocation();
switch (object.getId()) {
case 3566:
// Rope swing
start = object.getLocation().transform(dir.getStepX() << 1, dir.getStepY() << 1, 0);
Location end = object.getLocation().transform(-dir.getStepX() * 3, -dir.getStepY() * 3, 0);
if (AgilityHandler.hasFailed(player, 1, 0.1)) {
AgilityHandler.failWalk(player, 2, start, start.transform(-dir.getStepX(), -dir.getStepY(), 0), player.getLocation().transform(0, 0, -3), Animation.create(1105), 26, getHitAmount(player), "You missed the rope!").setEndAnimation(Animation.RESET);
return true;
}
AgilityHandler.forceWalk(player, -1, start, end, Animation.create(751), 25, getExp(player, 20.0), null);
GameWorld.submit(new Pulse(1, player) {
boolean finish;
@Override
public boolean pulse() {
if (!finish) {
player.getPacketDispatch().sendObjectAnimation(object, Animation.create(1052));
finish = true;
return false;
}
player.getPacketDispatch().sendObjectAnimation(object, Animation.create(-1));
return true;
}
});
return true;
case 3578:
// Pillars
handlePillarObstacle(player, object);
return true;
case 3565:
// Low wall
dir = Direction.getLogicalDirection(player.getLocation(), object.getLocation());
start = player.getLocation();
if (AgilityHandler.hasFailed(player, 1, 0.05)) {
end = start.transform(dir);
AgilityHandler.failWalk(player, 2, start, end, end, Animation.create(1106), 15, getHitAmount(player), "You lost your balance!");
AgilityHandler.forceWalk(player, -1, end, player.getLocation(), ForceMovement.WALK_ANIMATION, 10, 0.0, null, 4);
return true;
}
AgilityHandler.forceWalk(player, -1, start, start.transform(dir.getStepX() * 3, dir.getStepY() * 3, 0), Animation.create(1252), 6, getExp(player, 8.0), null);
return true;
case 3553:
case 3557:
handleLogBalance(player, object);
return true;
case 3570:
case 3571:
case 3572:
handlePlankObstacle(player, object);
return true;
case 3559:
case 3561:
handleBalancingLedge(player, object);
return true;
case 3564:
handleMonkeyBars(player, object);
return true;
case 3551:
handleBalancingRope(player, object);
return true;
case 3583:
handleHandHolds(player, object);
return true;
}
return false;
}
/**
* Handles the hand holds obstacle.
* @param player The player.
* @param object The object.
*/
private static void handleHandHolds(final Player player, final GameObject object) {
if (player.getSkills().getLevel(Skills.AGILITY) < 20) {
player.getPacketDispatch().sendMessage("You need an agility of at least 20 to get past this obstacle!");
return;
}
int mod = 0;
Direction direction = object.getDirection();
int x = object.getLocation().getX();
int y = object.getLocation().getY();
if ((x == 2785 && y == 9544) || (x == 2759 && y == 9566) || (x == 2792 && y == 9592)) {
mod = 4;
direction = Direction.get(direction.toInteger() + 2 & 3);
}
final int m = mod;
player.lock(5);
final Direction dir = direction;
final Direction faceDirection = Direction.get(object.getDirection().toInteger() - 1 & 3);
final Location start = player.getLocation();
player.getAppearance().setAnimations(Animation.create(1118 + m));
player.getAppearance().sync();
AgilityHandler.climb(player, -1, new Animation(1117 + m), start.transform(dir), 0.0, null);
player.addExtension(LogoutTask.class, new LocationLogoutTask(22, start));
GameWorld.submit(new Pulse(3, player) {
Location last = start.transform(dir);
int count;
@Override
public boolean pulse() {
if (++count == 1) {
if (AgilityHandler.hasFailed(player, 1, 0.15)) {
player.getAppearance().setAnimations();
player.getAppearance().sync();
LogoutTask task = player.getExtension(LogoutTask.class);
task.setDelay(2);
AgilityHandler.fail(player, 2, last.transform(0, 0, -3), Animation.create(1119 + m), getHitAmount(player), "You missed a hand hold!");
return true;
}
} else if (count == 6) {
player.getAppearance().setAnimations();
player.getAppearance().sync();
AgilityHandler.forceWalk(player, -1, last, last.transform(dir), Animation.create(1120 + m), 5, getExp(player, 22.0), null).setDirection(faceDirection);
return true;
}
AgilityHandler.forceWalk(player, -1, last, last = last.transform(dir), Animation.create(1118 + m), 5, 0.0, null).setDirection(faceDirection);
return false;
}
});
}
/**
* Handles the balancing rope obstacle.
* @param player The player.
* @param object The balancing rope object.
*/
private static void handleBalancingRope(final Player player, GameObject object) {
final Direction dir = object.getDirection();
boolean failed = AgilityHandler.hasFailed(player, 1, 0.1);
if (failed) {
Location end = player.getLocation().transform(dir);
AgilityHandler.forceWalk(player, -1, player.getLocation(), end, Animation.create(762), 10, 0.0, null);
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
Direction d = Direction.get((dir.toInteger() + 3) % 4);
AgilityHandler.fail(player, 2, player.getLocation().transform(d.getStepX() << 1, d.getStepY() << 1, -3), Animation.create(764), getHitAmount(player), "You lost your balance!");
return true;
}
});
return;
}
AgilityHandler.walk(player, -1, player.getLocation(), player.getLocation().transform(dir.getStepX() * 7, dir.getStepY() * 7, 0), Animation.create(155), getExp(player, 10.0), null);
}
/**
* Handles the monkey bars obstacle.
* @param player The player.
* @param object The object.
*/
private static void handleMonkeyBars(final Player player, GameObject object) {
player.lock(5);
final Direction dir = Direction.get((object.getDirection().toInteger() + 2) % 4);
player.getAppearance().setAnimations(Animation.create(745));
final Location start = player.getLocation();
ForceMovement.run(player, start.transform(dir), start.transform(dir.getStepX() << 1, dir.getStepY() << 1, 0), Animation.create(742), Animation.create(744));
player.addExtension(LogoutTask.class, new LocationLogoutTask(5, start));
GameWorld.submit(new Pulse(2, player) {
boolean failed;
int count;
@Override
public boolean pulse() {
if (++count == 1) {
if (failed = AgilityHandler.hasFailed(player, 1, 0.15)) {
setDelay(1);
player.animate(Animation.create(743));
return false;
}
setDelay(7);
AgilityHandler.walk(player, -1, player.getLocation().transform(dir), player.getLocation().transform(dir.getStepX() * 7, dir.getStepY() * 7, 0), Animation.create(662), 0.0, null);
player.addExtension(LogoutTask.class, new LocationLogoutTask(9, start));
} else if (count == 2) {
if (failed) {
player.getAppearance().setAnimations();
player.getAppearance().sync();
AgilityHandler.fail(player, 2, player.getLocation().transform(0, 0, -3), Animation.create(768), getHitAmount(player), "You missed a hand hold!");
return true;
}
AgilityHandler.forceWalk(player, -1, player.getLocation(), player.getLocation().transform(dir), Animation.create(743), 10, getExp(player, 14.0), null);
return true;
}
return false;
}
});
}
/**
* Handles the balancing ledge obstacle.
* @param player The player.
* @param object The object.
*/
private static void handleBalancingLedge(final Player player, GameObject object) {
final int diff = object.getId() == 3561 ? 0 : 1;
Location start = player.getLocation();
final Direction dir = Direction.getLogicalDirection(start, object.getLocation());
Location end = object.getLocation();
double xp = 0.0;
if (AgilityHandler.hasFailed(player, 1, 0.15)) {
player.lock(3);
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
Direction d = Direction.get((dir.toInteger() + 1) % 4);
AgilityHandler.fail(player, 1, player.getLocation().transform(d.getStepX(), d.getStepY(), -3), Animation.create(761 - diff), getHitAmount(player), "You lost your balance!");
return true;
}
});
} else {
xp = 16.0;
end = object.getLocation().transform(dir.getStepX() * 6, dir.getStepY() * 6, 0);
}
AgilityHandler.walk(player, -1, player.getLocation(), end, Animation.create(157 - diff), getExp(player, xp), null);
}
/**
* Handles the plank obstacle.
* @param player The player.
* @param object The object.
*/
private static void handlePlankObstacle(final Player player, GameObject object) {
final Direction dir = Direction.getLogicalDirection(player.getLocation(), object.getLocation());
final Location start = player.getLocation();
Location end = start.transform(dir.getStepX() * 7, dir.getStepY() * 7, 0);
player.faceLocation(end);
if (object.getCharge() == 500) { // Plank is broken
player.lock(7);
AgilityHandler.walk(player, -1, start, start.transform(dir.getStepX() * 2, dir.getStepY() * 2, 0), new Animation(1426), 0.0, null);
GameWorld.submit(new Pulse(3) {
boolean finish;
@Override
public boolean pulse() {
if (!finish) {
setDelay(2);
AgilityHandler.fail(player, 1, player.getLocation().transform(0, 0, -3), Animation.create(189), getHitAmount(player), "You stepped on a broken piece of plank!");
finish = true;
return false;
}
AgilityHandler.walk(player, -1, player.getLocation(), start.transform(dir), null, 0.0, null);
return true;
}
});
player.addExtension(LogoutTask.class, new LocationLogoutTask(8, start));
return;
}
AgilityHandler.walk(player, -1, start, end, ForceMovement.WALK_ANIMATION, getExp(player, 6.0), null);
}
/**
* Handles the pillars obstacle.
* @param player The player.
* @param object The object.
*/
private static void handlePillarObstacle(final Player player, GameObject object) {
final Direction dir = Direction.getLogicalDirection(player.getLocation(), object.getLocation());
AgilityHandler.forceWalk(player, -1, player.getLocation(), object.getLocation(), Animation.create(741), 10, 0, null);
final Location start = player.getLocation();
player.addExtension(LogoutTask.class, new LocationLogoutTask(12, start));
player.lock(12);
GameWorld.submit(new Pulse(2, player) {
int count = 0;
@Override
public boolean pulse() {
if (count == 0 && AgilityHandler.hasFailed(player, 1, 0.15)) {
Direction d = Direction.get((dir.toInteger() + 3) % 4);
player.unlock();
player.lock(2);
AgilityHandler.fail(player, 2, player.getLocation().transform(d.getStepX() << 1, d.getStepY() << 1, -3), Animation.create(764), getHitAmount(player), "You lost your balance!");
return true;
}
AgilityHandler.forceWalk(player, -1, player.getLocation(), player.getLocation().transform(dir), Animation.create(741), 10, count == 5 ? getExp(player, 18.0) : 0, null);
return ++count == 6;
}
});
}
/**
* Handles the log balance obstacle.
* @param player The player.
* @param object The log balance object.
*/
private static void handleLogBalance(final Player player, GameObject object) {
final Direction dir = Direction.getLogicalDirection(player.getLocation(), object.getLocation());
boolean failed = AgilityHandler.hasFailed(player, 1, 0.1);
if (failed) {
Location end = player.getLocation().transform(dir);
AgilityHandler.forceWalk(player, -1, player.getLocation(), end, Animation.create(762), 10, 0.0, null);
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
Direction d = Direction.get((dir.toInteger() + 3) % 4);
AgilityHandler.fail(player, 2, player.getLocation().transform(d.getStepX() << 1, d.getStepY() << 1, -3), Animation.create(764), getHitAmount(player), "You lost your balance!");
return true;
}
});
return;
}
AgilityHandler.walk(player, -1, player.getLocation(), player.getLocation().transform(dir.getStepX() * 7, dir.getStepY() * 7, 0), Animation.create(155), getExp(player, 12.0), null);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(3566).getConfigurations().put("option:swing-on", this);
ObjectDefinition.forId(3578).getConfigurations().put("option:jump-on", this);
ObjectDefinition.forId(3565).getConfigurations().put("option:climb-over", this);
ObjectDefinition.forId(3553).getConfigurations().put("option:walk-on", this);
ObjectDefinition.forId(3557).getConfigurations().put("option:walk-on", this);
ObjectDefinition.forId(3570).getConfigurations().put("option:walk-on", this);
ObjectDefinition.forId(3571).getConfigurations().put("option:walk-on", this);
ObjectDefinition.forId(3572).getConfigurations().put("option:walk-on", this);
ObjectDefinition.forId(3559).getConfigurations().put("option:walk-across", this);
ObjectDefinition.forId(3561).getConfigurations().put("option:walk-across", this);
ObjectDefinition.forId(3564).getConfigurations().put("option:swing-across", this);
ObjectDefinition.forId(3551).getConfigurations().put("option:walk-on", this);
ObjectDefinition.forId(3583).getConfigurations().put("option:climb-across", this);
return this;
}
@Override
public Location getDestination(Node node, Node n) {
GameObject object = (GameObject) n;
Direction dir = object.getDirection();
switch (object.getId()) {
case 3566:
return n.getLocation().transform(dir.getStepX() << 1, dir.getStepY() << 1, 0);
case 3564:
if (n.getLocation().getX() == 2771 && n.getLocation().getY() == 9570) {
return Location.create(2772, 9569, 3);
}
if (n.getLocation().getX() == 2771 && n.getLocation().getY() == 9577) {
return Location.create(2772, 9578, 3);
}
if (n.getLocation().getX() == 2793 && n.getLocation().getY() == 9566) {
return Location.create(2794, 9567, 3);
}
if (n.getLocation().getX() == 2793 && n.getLocation().getY() == 9559) {
return Location.create(2794, 9558, 3);
}
if (n.getLocation().getX() == 2781 && n.getLocation().getY() == 9545) {
return Location.create(2782, 9546, 3);
}
if (n.getLocation().getX() == 2774 && n.getLocation().getY() == 9545) {
return Location.create(2773, 9546, 3);
}
break;
case 3551:
return n.getLocation();
}
return null;
}
/**
* Gets the exp.
* @param player the player.
* @param exp the exp.
* @return the exp.
*/
private static double getExp(Player player, double exp) {
return player.getAchievementDiaryManager().getKaramjaGlove() > 1 ? exp + (exp * 0.10) : exp;
}
/**
* Gets the amount of damage to deal.
* @param player The player.
* @return The amount of damage.
*/
private static int getHitAmount(Player player) {
int hit = player.getSkills().getLifepoints() / 12;
if (hit < 2) {
hit = 2;
}
return hit;
}
}

View file

@ -0,0 +1,94 @@
package plugin.skill.agility.brimhaven;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.impl.Projectile;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.system.task.MovementHook;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.net.packet.PacketRepository;
import org.crandor.net.packet.context.CameraContext;
import org.crandor.net.packet.context.CameraContext.CameraType;
import org.crandor.net.packet.out.CameraViewPacket;
import org.crandor.tools.RandomFunction;
/**
* Handles the darts trap.
* @author Emperor
*/
public final class DartTrap implements MovementHook {
@Override
public boolean handle(Entity e, final Location l) {
final Direction dir = e.getDirection();
final Player player = (Player) e;
final Location start = l.transform(-dir.getStepX(), -dir.getStepY(), 0);
e.lock(6);
e.addExtension(LogoutTask.class, new LocationLogoutTask(13, start));
final Location startProj = l.transform(dir.getStepX() * 5, dir.getStepY() * 5, 0);
GameWorld.submit(new Pulse(2, e) {
boolean failed;
int count;
@Override
public boolean pulse() {
if (++count == 1) {
if (failed = AgilityHandler.hasFailed(player, 40, 0.15)) {
if (player.getSkills().getLevel(Skills.AGILITY) < 40) {
player.getPacketDispatch().sendMessage("You need an agility of at least 40 to get past this trap!");
}
Projectile.create(startProj, l, 270, 0, 10, 46, 85, 5, 11).send();
setDelay(3);
} else {
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.POSITION, startProj.getX() + (dir.getStepX() * 4), startProj.getY() + (dir.getStepY() * 4), 350, 1, 100));
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.ROTATION, l.getX(), l.getY(), 350, 1, 100));
Projectile.create(startProj, l.transform(-dir.getStepX() * 4, -dir.getStepY() * 4, 0), 270, 0, 0, 46, 200, 5, 11).send();
}
} else if (count == 2) {
if (failed) {
int hit = player.getSkills().getLifepoints() / 12;
if (hit < 2) {
hit = 2;
}
setDelay(1);
AgilityHandler.failWalk(player, 1, l, start, start, Animation.create(1114), 10, hit, null).setDirection(dir);
} else {
if (dir.toInteger() % 2 != 0) {
int mod = dir == Direction.WEST ? -1 : 1;
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.POSITION, l.getX() - (5 * mod), l.getY() - (5 * mod), 400, 8, 6));
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.ROTATION, l.getX() + (2 * mod), l.getY(), 350, 8, 1));
} else {
int mod = dir == Direction.SOUTH ? -1 : 1;
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.POSITION, l.getX() + (5 * mod), l.getY() - (5 * mod), 400, 8, 6));
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.ROTATION, l.getX(), l.getY() + (2 * mod), 350, 8, 1));
}
player.lock(7);
player.animate(new Animation(1110, 20));
setDelay(5);
}
} else if (count == 3) {
if (failed) {
player.getPacketDispatch().sendMessage("You were hit by some darts, something on them makes you feel dizzy!");
player.getSkills().updateLevel(Skills.AGILITY, -(2 + RandomFunction.randomize(2)), 0);
return true;
}
setDelay(2);
AgilityHandler.walk(player, -1, l, l.transform(dir.getStepX() << 1, dir.getStepY() << 1, 0), null, 30.0, null);
} else if (count == 4) {
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.RESET, 0, 0, 0, 0, 0));
return true;
}
return false;
}
});
return false;
}
}

View file

@ -0,0 +1,53 @@
package plugin.skill.agility.brimhaven;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.system.task.MovementHook;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
/**
* Handles floor spikes trap.
* @author Emperor
*/
public final class FloorSpikes implements MovementHook {
@Override
public boolean handle(Entity e, final Location l) {
final Direction dir = e.getDirection();
final Player player = (Player) e;
final Location start = l.transform(-dir.getStepX(), -dir.getStepY(), 0);
e.lock(5);
e.addExtension(LogoutTask.class, new LocationLogoutTask(5, start));
GameWorld.submit(new Pulse(3, e) {
@Override
public boolean pulse() {
player.getPacketDispatch().sendObjectAnimation(RegionManager.getObject(l), Animation.create(1111));
if (AgilityHandler.hasFailed(player, 20, 0.25)) {
if (player.getSkills().getLevel(Skills.AGILITY) < 20) {
player.getPacketDispatch().sendMessage("You need an agility of at least 20 to get past this trap!");
}
int hit = player.getSkills().getLifepoints() / 12;
if (hit < 2) {
hit = 2;
}
AgilityHandler.failWalk(player, 1, player.getLocation(), start, start, Animation.create(1114), 10, hit, "You were hit by some floor spikes!").setDirection(dir);
;
} else {
AgilityHandler.forceWalk(player, -1, l, l.transform(dir.getStepX() << 1, dir.getStepY() << 1, 0), Animation.create(1115), 20, 26, null);
}
return true;
}
});
return false;
}
}

View file

@ -0,0 +1,53 @@
package plugin.skill.agility.brimhaven;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.system.task.MovementHook;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.game.world.update.flag.context.Graphics;
/**
* Handles the pressure pad trap.
* @author Emperor
*/
public final class PressurePad implements MovementHook {
@Override
public boolean handle(Entity e, final Location dest) {
final Direction dir = e.getDirection();
final Player player = (Player) e;
final Location start = dest.transform(-dir.getStepX(), -dir.getStepY(), 0);
e.lock(5);
e.addExtension(LogoutTask.class, new LocationLogoutTask(5, start));
GameWorld.submit(new Pulse(3, e) {
@Override
public boolean pulse() {
Graphics.send(Graphics.create(271), dest);
if (AgilityHandler.hasFailed(player, 20, 0.25)) {
if (player.getSkills().getLevel(Skills.AGILITY) < 20) {
player.getPacketDispatch().sendMessage("You need an agility of at least 20 to get past this trap!");
}
int hit = player.getSkills().getLifepoints() / 12;
if (hit < 2) {
hit = 2;
}
AgilityHandler.failWalk(player, 1, player.getLocation(), start, start, Animation.create(1114), 10, hit, "You were hit by some falling rocks!").setDirection(dir);
;
} else {
AgilityHandler.forceWalk(player, -1, dest, dest.transform(dir.getStepX() << 1, dir.getStepY() << 1, 0), Animation.create(1115), 20, 26, null);
}
return true;
}
});
return false;
}
}

View file

@ -0,0 +1,67 @@
package plugin.skill.agility.brimhaven;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.system.task.MovementHook;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
/**
* Handles the spinning blades trap.
* @author Emperor
*/
public final class SpinningBlades implements MovementHook {
@Override
public boolean handle(Entity e, final Location l) {
final Direction dir = e.getDirection();
final Player player = (Player) e;
final Location start = l.transform(-dir.getStepX(), -dir.getStepY(), 0);
e.lock(5);
e.addExtension(LogoutTask.class, new LocationLogoutTask(5, start));
GameWorld.submit(new Pulse(3, e) {
@Override
public boolean pulse() {
sendObjectAnimation(player, l);
if (AgilityHandler.hasFailed(player, 40, 0.15)) {
if (player.getSkills().getLevel(Skills.AGILITY) < 40) {
player.getPacketDispatch().sendMessage("You need an agility of at least 40 to get past this trap!");
}
int hit = player.getSkills().getLifepoints() / 12;
if (hit < 2) {
hit = 2;
}
AgilityHandler.failWalk(player, 1, player.getLocation(), start, start, Animation.create(1114), 10, hit, "You were hit by the spinning blades.").setDirection(dir);
} else {
AgilityHandler.forceWalk(player, -1, l, l.transform(dir.getStepX() << 1, dir.getStepY() << 1, 0), Animation.create(1115), 20, 26, null);
}
return true;
}
});
return false;
}
/**
* Sends the object animation for the spinning blades.
* @param player The player.
* @param l The location.
*/
private static void sendObjectAnimation(Player player, Location l) {
if (l.equals(Location.create(2778, 9579, 3))) {
l = Location.create(2777, 9580, 3);
} else if (l.equals(Location.create(2783, 9574, 3))) {
l = Location.create(2782, 9573, 3);
} else if (l.equals(Location.create(2778, 9557, 3))) {
l = Location.create(2777, 9556, 3);
}
player.getPacketDispatch().sendObjectAnimation(RegionManager.getObject(l), Animation.create(1107));
}
}

View file

@ -0,0 +1,552 @@
package plugin.skill.agility.pyramid;
import org.crandor.cache.def.impl.ConfigFileDefinition;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.ClimbActionHandler;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.agility.AgilityCourse;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.PluginManager;
/**
* Handles the agility pryamid course.
* @author Vexia
*/
@InitializablePlugin
public final class AgilityPyramidCourse extends AgilityCourse {
/**
* The pyramid top item.
*/
private static final Item PYRAMID_TOP = new Item(6970);
/**
* The config id to use.
*/
private static final int CONFIG_ID = 640;
/**
* The jump gap location data.
*/
private static final Location[][] GAP_LOCATIONS = new Location[][] { { new Location(3356, 2847, 2), Location.create(3357, 2847, 2), Location.create(3356, 2846, 2), Location.create(3357, 2846, 2), Location.create(3356, 2849, 2), Location.create(3357, 2849, 2) }, { new Location(3364, 2833, 2), Location.create(3364, 2834, 2), Location.create(3366, 2834, 2), Location.create(3366, 2833, 2), Location.create(3363, 2834, 2), Location.create(3363, 2833, 2) }, { new Location(3370, 2841, 3), new Location(3371, 2841, 3), Location.create(3370, 2840, 3), Location.create(3371, 2840, 3), Location.create(3370, 2843, 3), Location.create(3371, 2843, 3) }, { new Location(3040, 4697, 2), Location.create(3041, 4697, 2), Location.create(3041, 4696, 2), Location.create(3040, 4696, 2), Location.create(3041, 4699, 2), Location.create(3040, 4699, 2) }, { new Location(3048, 4695, 2), Location.create(3049, 4695, 2), Location.create(3048, 4694, 2), Location.create(3049, 4694, 2), Location.create(3048, 4697, 2), Location.create(3049, 4697, 2) }, { Location.create(3046, 4697, 3), Location.create(3047, 4697, 3), Location.create(3046, 4696, 3), Location.create(3047, 4696, 3), Location.create(3046, 4699, 3), Location.create(3047, 4699, 3) } };
/**
* The ledge crossing location data.
*/
private static final Location[][] LEDGE_LOCATIONS = new Location[][] { { new Location(3366, 2851, 1), new Location(3364, 2851, 1), Location.create(3368, 2851, 1), Location.create(3363, 2851, 1), Location.create(3367, 2851, 1), Location.create(3364, 2851, 1) }, { new Location(3362, 2831, 1), new Location(3360, 2831, 1), Location.create(3364, 2832, 1), Location.create(3359, 2832, 1), Location.create(3360, 2832, 1), Location.create(3363, 2832, 1) }, { new Location(3372, 2837, 2), new Location(3372, 2839, 2), Location.create(3372, 2841, 2), Location.create(3372, 2836, 2), Location.create(3372, 2837, 2), Location.create(3372, 2840, 2) }, { new Location(3358, 2843, 3), new Location(3358, 2845, 3), Location.create(3359, 2842, 3), Location.create(3359, 2847, 3), Location.create(3359, 2846, 3), Location.create(3359, 2843, 3) } };
/**
* The gap crossing location data.
*/
private static final Location[][] GAP_CROSS_LOCATIONS = new Location[][] { { new Location(3368, 2831, 1), new Location(3370, 2831, 1), Location.create(3372, 2832, 1), Location.create(3367, 2832, 1), Location.create(3371, 2832, 1), Location.create(3368, 2832, 1) }, { new Location(3356, 2837, 2), new Location(3356, 2839, 2), Location.create(3357, 2841, 2), Location.create(3357, 2836, 2), Location.create(3357, 2840, 2), Location.create(3357, 2837, 2) }, { new Location(3360, 2849, 2), new Location(3362, 2849, 2), Location.create(3359, 2849, 2), Location.create(3364, 2849, 2), Location.create(3363, 2849, 2), Location.create(3360, 2849, 2) } };
/**
* Constructs a new {@code AgilityPyramidCourse} {@code Object}.
*/
public AgilityPyramidCourse() {
this(null);
}
/**
* Constructs a new {@code AgilityPyramidCourse} {@code Object}.
* @param player the player.
*/
public AgilityPyramidCourse(Player player) {
super(player, 5, 0);
}
@Override
public void configure() {
ObjectDefinition.forId(16535).getConfigurations().put("option:climb", this);
ObjectDefinition.forId(16536).getConfigurations().put("option:climb", this);
ObjectDefinition.forId(10851).getConfigurations().put("option:climb", this);
ObjectDefinition.forId(10855).getConfigurations().put("option:enter", this);
ObjectDefinition.forId(10856).getConfigurations().put("option:enter", this);
ObjectDefinition.forId(10860).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10861).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10862).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10863).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10864).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10868).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10867).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10882).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10883).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10884).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10885).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10886).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10887).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10888).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10889).getConfigurations().put("option:cross", this);
ObjectDefinition.forId(10859).getConfigurations().put("option:jump", this);
ObjectDefinition.forId(10857).getConfigurations().put("option:climb-up", this);
ObjectDefinition.forId(10858).getConfigurations().put("option:climb-down", this);
ObjectDefinition.forId(10865).getConfigurations().put("option:climb-over", this);
RollingBlock.BlockSets.values();
PluginManager.definePlugin(new MovingBlockNPC());
PluginManager.definePlugin(new AgilityPyramidZone());
}
@Override
public boolean handle(final Player player, Node node, String option) {
getCourse(player); // Sets the extension.
final GameObject object = (GameObject) node;
if (object.getLocation().getDistance(player.getLocation()) >= 3) {
player.getPacketDispatch().sendMessage("I can't reach that!");
return true;
}
switch (object.getId()) {
case 16535:
case 16536:
handleRockClimb(player, object);
break;
case 10865:
handleLowWall(player, object);
break;
case 10888:
case 10889:
case 10860:
case 10886:
case 10887:
handleLedge(player, object);
break;
case 10868:
case 10867:
handlePlank(player, object);
break;
case 10882:
case 10883:
case 10884:
case 10885:
case 10861:
case 10862:
case 10863:
case 10864:
handleGapCross(player, object);
break;
case 10857:
case 10858:
handleStairs(player, object);
break;
case 10851:
handlePyramidTop(player, object);
break;
case 10859:
handleJumpGap(player, object);
break;
case 10855:
case 10856:
addConfig(player, 10869, 0, true);
if (player.getConfigManager().get(640) == 505 || player.getConfigManager().get(640) == 515) {
player.getSkills().addExperience(Skills.AGILITY, 300, true);
}
player.getDialogueInterpreter().sendDialogue("You climb down the steep passage. It leads to the base of the", "pyramid.");
player.getProperties().setTeleportLocation(Location.create(3364, 2830, 0));
break;
}
return true;
}
/**
* Handles the stairs.
* @param player the player.
* @param object the object.
*/
private void handleStairs(final Player player, final GameObject object) {
Direction dir = Direction.getLogicalDirection(player.getLocation(), object.getLocation());
Location dest = null;
if (dir == Direction.NORTH) {
dest = object.getLocation().transform(0, 2, 1);
} else if (dir == Direction.SOUTH) {
dest = object.getLocation().transform(0, -1, -1);
}
if (object.getLocation().equals(Location.create(3360, 2837, 3))) {
dest = Location.create(3040, 4695, 2);
} else if (object.getLocation().equals(Location.create(3040, 4693, 2))) {
dest = Location.create(3360, 2836, 3);
} else if (object.getLocation().equals(new Location(3354, 2831, 0))) {
addConfig(player, 10869, 0, true);
}
ClimbActionHandler.climb(player, null, dest);
}
/**
* Handles the rock climbing obstacle.
* @param player the player.
* @param object the object.
*/
private void handleRockClimb(final Player player, final GameObject object) {
final boolean scale = player.getLocation().getX() < object.getLocation().getX();
final Location end = object.getLocation().transform(scale ? 2 : -2, 0, 0);
if (object.getId() == 16536 && player.getSkills().getStaticLevel(Skills.AGILITY) < 30) {
player.getPacketDispatch().sendMessage("You must be level 30 agility or higher to climb down the rocks.");
return;
}
if (!scale) {
ForceMovement.run(player, player.getLocation(), end, Animation.create(740), Animation.create(740), Direction.WEST, 13).setEndAnimation(Animation.RESET);
} else {
ForceMovement.run(player, player.getLocation(), end, Animation.create(1148), Animation.create(1148), Direction.WEST, 13).setEndAnimation(Animation.RESET);
}
}
/**
* Handles the low wall obstacle.
* @param player the player.
* @param object the object.
*/
private void handleLowWall(final Player player, final GameObject object) {
Direction d = Direction.getDirection(player.getLocation(), object.getLocation());
final boolean fail = hasFailed(player);
if (player.getLocation().equals(Location.create(3355, 2848, 1)) || player.getLocation().equals(Location.create(3359, 2838, 3))) {
d = Direction.NORTH;
} else if (player.getLocation().equals(Location.create(3355, 2850, 1)) || player.getLocation().equals(Location.create(3359, 2840, 3))) {
d = Direction.SOUTH;
} else if (player.getLocation().equals(Location.create(3046, 4694, 2)) || player.getLocation().equals(Location.create(3355, 2850, 1)) || player.getLocation().equals(Location.create(3041, 4702, 2)) || player.getLocation().equals(new Location(3369, 2834, 2))) {
d = Direction.EAST;
} else if (player.getLocation().equals(Location.create(3048, 4694, 2)) || player.getLocation().equals(Location.create(3371, 2834, 2)) || player.getLocation().equals(Location.create(3043, 4702, 2))) {
d = Direction.WEST;
}
player.lock(4);
player.getPacketDispatch().sendMessage("You climb the low wall...");
if (fail) {
Location end = player.getLocation().transform(d, 1);
player.lock(3);
AgilityHandler.failWalk(player, 2, player.getLocation(), end, end, Animation.create(1106), 15, getHitAmount(player), "You lost your balance!");
AgilityHandler.forceWalk(player, -1, end, player.getLocation(), ForceMovement.WALK_ANIMATION, 10, 0.0, null, 4);
return;
}
AgilityHandler.forceWalk(player, 0, player.getLocation(), player.getLocation().transform(d, 2), Animation.create(1252), 6, 8, "... and make it over.");
player.animate(Animation.RESET, 4);
}
/**
* Handles the ledge crossing obstacle.
* @param player the player.
* @param object the object.
*/
private void handleLedge(final Player player, final GameObject object) {
Direction d = Direction.getLogicalDirection(player.getLocation(), getLedgeLocation(player, object));
final Direction dir = d;
final int diff = object.getRotation() == 3 && dir == Direction.EAST ? 1 : object.getRotation() == 3 && dir == Direction.WEST ? 0 : d == Direction.EAST || (d == Direction.SOUTH && object.getRotation() != 0) || d == Direction.NORTH ? 0 : 1;
final boolean fail = hasFailed(player);
final Location end = player.getLocation().transform(dir.getStepX() * (fail ? 3 : 5), dir.getStepY() * (fail ? 3 : 5), 0);
player.getPacketDispatch().sendMessage("You put your foot on the ledge and try to edge across...");
if (fail) {
player.lock(4);
AgilityHandler.walk(player, -1, player.getLocation(), end, Animation.create(157 - diff), 0.0, "You slip and fall to the level below.");
GameWorld.submit(new Pulse(3, player) {
@Override
public boolean pulse() {
Location dest = end;
int x = 0, y = 0;
switch (dir) {
case NORTH:
case SOUTH:
if (object.getRotation() == 2) {
x = 2;
} else {
x = -2;
}
break;
case WEST:
case EAST:
if (object.getRotation() == 3) {
y = -2;
} else if (object.getRotation() == 1) {
y = 2;
}
break;
default:
break;
}
AgilityHandler.fail(player, 1, transformLevel(dest.transform(x, y, 0)), Animation.create(761 - diff), 10, null);
return true;
}
});
return;
}
AgilityHandler.walk(player, 3, player.getLocation(), end, Animation.create(157 - diff), 52, "You skillfully edge across the gap.");
}
/**
* Handles the plank crossin obstacle.
* @param player the player.
* @param object the object.
*/
private void handlePlank(final Player player, final GameObject object) {
final boolean custom = object.getLocation().equals(new Location(3365, 2835, 3)) || object.getLocation().equals(new Location(3370, 2835, 3));
final Direction dir = custom ? Direction.EAST : Direction.getLogicalDirection(player.getLocation(), object.getLocation());
final boolean fail = hasFailed(player);
final Location end = object.getLocation().transform(object.getId() != 10868 ? dir : dir.getOpposite(), fail ? 2 : 5);
AgilityHandler.walk(player, fail ? -1 : 1, player.getLocation(), end, Animation.create(155), fail ? 0.0 : 56.4, fail ? null : "You walk carefully across the slippery plank...");
if (fail) {
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
final Location dest = transformLevel(end.transform(!custom ? 2 : 0, custom ? -2 : 0, 0));
AgilityHandler.failWalk(player, 2, end, dest, dest, Animation.create(764), 10, 10, null);
return true;
}
});
}
}
/**
* Handles the gab crossing obstacle.
* @param player the player.
* @param object the object.
*/
private void handleJumpGap(Player player, GameObject object) {
final Direction dir = Direction.getDirection(player.getLocation(), getGapLocation(player, object));
final boolean fail = hasFailed(player);
player.getPacketDispatch().sendMessage("You jump the gap...");
if (fail) {
final boolean regular = object.getRotation() == 0 || object.getRotation() == 3;
Location end = player.getLocation().transform(dir, 1);
Location dest = object.getLocation().transform(dir, 1);
if (!regular) {
dest = dest.transform(dir == Direction.NORTH || dir == Direction.SOUTH ? 2 : 0, dir == Direction.SOUTH ? 1 : 0, 0);
} else {
dest = dest.transform(dir == Direction.NORTH || dir == Direction.SOUTH ? -1 : dir == Direction.WEST ? 1 : 0, dir == Direction.SOUTH ? 1 : dir == Direction.WEST || dir == Direction.EAST ? -1 : 0, 0);
}
dest = transformLevel(dest);
player.lock(8);
AgilityHandler.forceWalk(player, -1, player.getLocation(), end, Animation.create(3068), 10, 0.0, "... and miss your footing.");
AgilityHandler.fail(player, 8, dest, null, 8, null);
return;
}
player.lock(4);
AgilityHandler.forceWalk(player, 2, player.getLocation(), player.getLocation().transform(dir, 3), Animation.create(3067), 20, 22, null);
}
/**
* Handles the gap cross obstacle.
* @param player the player.
* @param object the object.
*/
private void handleGapCross(final Player player, final GameObject object) {
final Direction dir = Direction.getLogicalDirection(player.getLocation(), getGapCrossLocation(player, object));
final boolean fail = hasFailed(player);
final Location end = player.getLocation().transform(dir, fail ? 4 : 5);
final int rot = object.getRotation();
int mod = player.getLocation().equals(new Location(3359, 2849, 2)) ? 0 : player.getLocation().equals(new Location(3357, 2841, 2)) ? 1 : player.getLocation().equals(new Location(3367, 2832, 1)) ? 1 : player.getLocation().equals(new Location(3372, 2832, 1)) ? 0 : object.getLocation().equals(new Location(3370, 2831, 1)) ? 0 : rot == 1 && dir == Direction.EAST ? 0 : rot == 3 && (dir == Direction.WEST || dir == Direction.EAST) ? 1 : rot == 0 && dir == Direction.SOUTH ? 1 : dir == Direction.WEST && rot != 3 || dir == Direction.EAST ? 1 : 0;
final Animation animation = Animation.create(387 - mod);
if (fail) {
Location dest = object.getLocation().transform(dir, 1);
dest = rot == 1 && dir == Direction.EAST ? dest.transform(1, 2, 0) : rot == 1 && dir == Direction.WEST ? dest.transform(0, -2, 0) : dest.transform(dir == Direction.NORTH || dir == Direction.SOUTH ? -1 : dir == Direction.WEST ? 1 : 0, dir == Direction.SOUTH ? 1 : dir == Direction.WEST || dir == Direction.EAST ? -1 : 0, 0);
AgilityHandler.walk(player, -1, player.getLocation(), end, animation, 10, null);
AgilityHandler.fail(player, 3, transformLevel(dest), null, 8, null);
// player.animate(Animation.create(3056 - mod), 2);
GameWorld.submit(new Pulse(3, player) {
@Override
public boolean pulse() {
player.getAppearance().setDefaultAnimations();
player.getAppearance().sync();
return true;
}
});
return;
}
AgilityHandler.walk(player, 4, player.getLocation(), end, animation, 22, null);
}
/**
* Handles the pyramid top obstacle.
* @param player the player.
* @param object the object.
*/
private void handlePyramidTop(final Player player, final GameObject object) {
player.animate(Animation.create(3063));
GameWorld.submit(new Pulse(3, player) {
@Override
public boolean pulse() {
if (player.getConfigManager().get(640) == 505 || player.getConfigManager().get(640) == 515) {
player.getPacketDispatch().sendMessage("You find nothing on top of the pyramid.");
return true;
}
addConfig(player, 10869, 1, true);
player.getInventory().add(PYRAMID_TOP, player);
player.getDialogueInterpreter().sendItemMessage(PYRAMID_TOP, "You find a golden pyramid!");
return true;
}
});
}
/**
* Transforms a pyramid level.
* @param location the location.
* @return the location.
*/
public static Location transformLevel(Location location) {
int xDiff = 320;
int yDiff = 1856;
if (location.getRegionId() == 12105 && location.getZ() == 2) {
return new Location(location.getX() + xDiff, location.getY() - yDiff, 3);
}
return location.transform(0, 0, -1);
}
/**
* Gets the gap location.
* @param player the player.
* @param object the obejct.
* @return the location.
*/
private Location getGapLocation(Player player, GameObject object) {
final Location[] data = getLocationData(GAP_LOCATIONS, object.getLocation());
return getClosest(new Location[] { data[0], data[1] }, player.getLocation());
}
/**
* Gets the gap cross location.
* @param player the player.
* @param object the obejct.
* @return the location.
*/
private Location getGapCrossLocation(Player player, GameObject object) {
final Location[] data = getLocationData(GAP_CROSS_LOCATIONS, object.getLocation());
return getClosest(new Location[] { data[4], data[5] }, player.getLocation());
}
/**
* Gets the ledge location.
* @param player the player.
* @param object the object.
* @return the location.
*/
private Location getLedgeLocation(final Player player, final GameObject object) {
final Location[] data = getLocationData(LEDGE_LOCATIONS, object.getLocation());
return getClosest(new Location[] { data[4], data[5] }, player.getLocation());
}
/**
* Gets the closest location.
* @param data the data.
* @param location the location.
* @return the closest location.
*/
private Location getClosest(Location[] data, Location location) {
Location closest = null;
for (Location l : data) {
if (closest == null || l.getDistance(location) < closest.getDistance(location)) {
closest = l;
}
}
return closest;
}
/**
* Gets the location data.
* @param data the data.
* @param location the location.
* @return the data.
*/
private Location[] getLocationData(Location[][] data, Location location) {
for (int i = 0; i < data.length; i++) {
for (Location l : data[i]) {
if (l.equals(location)) {
return data[i];
}
}
}
return null;
}
/**
* Checks if the player has failed.
* @param player the player.
* @return {@code True} if so.
*/
private boolean hasFailed(final Player player) {
return hasFailed(player, 0.009000);
}
/**
* Checks if the player has failed.
* @param player the player.
* @param mod the mod.
* @return {@code True} if so.
*/
private boolean hasFailed(final Player player, double mod) {
return AgilityHandler.hasFailed(player, 10, mod);
}
/**
* Sets the config id.
* @param player the player.
* @param object the object.
* @param value the value.
*/
public static void addConfig(final Player player, final int objectId, final int value, boolean save) {
final ConfigFileDefinition definition = ConfigFileDefinition.forId(ObjectDefinition.forId(objectId).getConfigFileId());
final int oldVal = (definition.getValue(player) << definition.getBitShift());
final int newVal = (value << definition.getBitShift());
player.getConfigManager().set(CONFIG_ID, (player.getConfigManager().get(CONFIG_ID) - oldVal) + newVal, save);
}
/**
* Sets the config id.
* @param player the player.
* @param object the object.
* @param value the value.
* @param save if we save.
*/
public static void addConfig(final Player player, final GameObject object, final int value, boolean save) {
addConfig(player, object.getId(), value, save);
}
@Override
public Location getDestination(Node node, Node n) {
switch (n.getId()) {
case 16535:
case 16536:
return n.getLocation().transform(node.getLocation().getX() < n.getLocation().getX() ? -1 : 1, 0, 0);
case 10865:
return null;
case 10857:
return n.getLocation().transform(0, -1, 0);
case 10858:
return n.getLocation().transform(0, 2, 0);
case 10859:
return getClosest(getLocationData(GAP_LOCATIONS, n.getLocation()), node.getLocation());
case 10860:
case 10886:
case 10887:
case 10888:
case 10889:
return getClosest(getLocationData(LEDGE_LOCATIONS, n.getLocation()), node.getLocation());
case 10868:
case 10867:
return n.getLocation();
case 10882:
case 10883:
case 10884:
case 10885:
case 10861:
case 10862:
case 10863:
case 10864:
if (n.getId() == 10863 && n.getLocation().equals(new Location(3372, 2832, 1))) {
return Location.create(3372, 2832, 1);
}
return getClosest(getLocationData(GAP_CROSS_LOCATIONS, n.getLocation()), node.getLocation());
}
return null;
}
@Override
public AgilityCourse createInstance(Player player) {
return new AgilityPyramidCourse(player);
}
}

View file

@ -0,0 +1,76 @@
package plugin.skill.agility.pyramid;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.task.MovementHook;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.zone.MapZone;
import org.crandor.game.world.map.zone.ZoneBorders;
import org.crandor.game.world.map.zone.ZoneBuilder;
import org.crandor.plugin.Plugin;
import java.util.HashMap;
import java.util.Map;
/**
* Represents the agility pyramid area.
* @author 'Vexia
* @version 1.0
*/
public final class AgilityPyramidZone extends MapZone implements Plugin<Object> {
/**
* The location based traps.
*/
public static final Map<Location, MovementHook> LOCATION_TRAPS = new HashMap<>();
/**
* Constructs a new {@code AgilityPyramid} {@code Object}.
* @param name the name.
* @param overlappable if overlappable.
* @param restrictions the restrictions.
*/
public AgilityPyramidZone() {
super("agility pyramid", true);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ZoneBuilder.configure(this);
return this;
}
@Override
public boolean enter(Entity e) {
if (e instanceof Player) {
final Player player = (Player) e;
AgilityPyramidCourse.addConfig(player, 10872, 1, true);
AgilityPyramidCourse.addConfig(player, 10873, 3, true);
}
return super.enter(e);
}
@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 Object fireEvent(String identifier, Object... args) {
return null;
}
@Override
public void configure() {
register(new ZoneBorders(3352, 2826, 3378, 2854));
register(new ZoneBorders(3007, 4672, 3071, 4735));
}
}

View file

@ -0,0 +1,175 @@
package plugin.skill.agility.pyramid;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.npc.AbstractNPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.task.MovementHook;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
/**
* The moving block npc.
* @author 'Vexia
* @version 1.0
*/
public final class MovingBlockNPC extends AbstractNPC {
/**
* The tile locations.
*/
private static final Location[][] LOCATIONS = new Location[][] { { Location.create(3366, 2847, 3), Location.create(3367, 2847, 3), Location.create(3367, 2848, 3), Location.create(3366, 2848, 3), Location.create(3365, 2847, 3), Location.create(3365, 2848, 3), Location.create(3368, 2847, 3), Location.create(3368, 2848, 3) }, { Location.create(3374, 2847, 1), Location.create(3374, 2848, 1), Location.create(3375, 2848, 1), Location.create(3375, 2847, 1), Location.create(3374, 2849, 1), Location.create(3375, 2849, 1), Location.create(3374, 2846, 1), Location.create(3375, 2846, 1) } };
/**
* The next move delay.
*/
private int nextMove;
/**
* If its moving.
*/
private boolean moving;
/**
* Constructs a new {@code MovingBlockNPC} {@code Object}.
*/
public MovingBlockNPC() {
super(-1, null);
}
/**
* Constructs a new {@code MovingBlockNPC} {@code Object}.
* @param id the id.
* @param location the location.
*/
public MovingBlockNPC(int id, Location location) {
super(id, location, false);
}
@Override
public void tick() {
super.tick();
if (nextMove < GameWorld.getTicks() && nextMove != -1) {
Direction dir = getId() == 3124 ? Direction.EAST : Direction.NORTH;
Location loc = getLocation().transform(dir, 2);
getWalkingQueue().reset();
getWalkingQueue().addPath(loc.getX(), loc.getY());
for (Player p : RegionManager.getLocalPlayers(getTileLocations()[0], 2)) {
checkBlock(p);
}
moving = true;
GameWorld.submit(new Pulse(1, this) {
int counter;
@Override
public boolean pulse() {
switch (++counter) {
case 1:
for (Player p : RegionManager.getLocalPlayers(getTileLocations()[0], 2)) {
checkBlock(p);
}
break;
case 3:
getWalkingQueue().reset();
getWalkingQueue().addPath(getProperties().getSpawnLocation().getX(), getProperties().getSpawnLocation().getY());
nextMove = GameWorld.getTicks() + 13;
break;
case 5:
moving = false;
return true;
}
return false;
}
});
nextMove = -1;
}
}
@Override
public void init() {
super.init();
final MovingBlockTrap trap = new MovingBlockTrap();
for (Location l : getTileLocations()) {
AgilityPyramidZone.LOCATION_TRAPS.put(l, trap);
}
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return new MovingBlockNPC(id, location);
}
/**
* Checks if a player is going to get hit by a block.
* @param player the player.
*/
public void checkBlock(final Player player) {
if (player.getAttribute("block-move", -1) > GameWorld.getTicks()) {
return;
}
Location[] locs = getTileLocations();
for (int i = 0; i < 4; i++) {
if (locs[i].equals(player.getLocation())) {
GameWorld.submit(new Pulse(1, player) {
@Override
public boolean pulse() {
boolean close = getProperties().getSpawnLocation().getDistance(player.getLocation()) > (getId() == 3124 ? 2 : 2.3);
Location dest = null;
if (getId() == 3124) {
if (player.getLocation().getY() == 2847) {
dest = Location.create(3376, 2847, 1);
} else if (player.getLocation().getY() == 2848) {
dest = Location.create(3376, 2848, 1);
}
} else {
if (player.getLocation().getX() == 3366) {
dest = Location.create(3366, 2849, 3);
} else if (player.getLocation().getX() == 3367) {
dest = Location.create(3367, 2849, 3);
}
}
player.lock(4);
player.setAttribute("block-move", GameWorld.getTicks() + 4);
AgilityHandler.failWalk(player, close ? 1 : 3, player.getLocation(), dest, AgilityPyramidCourse.transformLevel(dest), Animation.create(3066), 10, 8, null, getId() == 3124 ? Direction.WEST : Direction.SOUTH);
return true;
}
});
return;
}
}
}
/**
* Gets the tile locations.
* @return the locations.
*/
public Location[] getTileLocations() {
return LOCATIONS[3125 - getId()];
}
@Override
public int[] getIds() {
return new int[] { 3124, 3125 };
}
/**
* The movement hook to handle a moving block.
* @author 'Vexia
* @version 1.0
*/
public final class MovingBlockTrap implements MovementHook {
@Override
public boolean handle(Entity e, Location l) {
if (moving) {
return false;
}
return true;
}
}
}

View file

@ -0,0 +1,164 @@
package plugin.skill.agility.pyramid;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.system.task.MovementHook;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
/**
* Represents the rolling block obstacle.
* @author 'Vexia
* @version 1.0
*/
public final class RollingBlock implements MovementHook {
@Override
public boolean handle(final Entity e, final Location dest) {
final Player player = (Player) e;
final BlockSets set = BlockSets.forLocation(dest);
final GameObject stone = RegionManager.getObject(set.getBlockLocation());
final boolean backwards = isBackwards(stone.getDirection(), player.getDirection(), stone.getRotation());
final boolean fail = backwards || AgilityHandler.hasFailed(player, 2, 0.3);
player.lock(5);
AgilityPyramidCourse.addConfig(player, stone, 1, false);
e.addExtension(LogoutTask.class, new LocationLogoutTask(5, player.getLocation()));
if (fail) {
GameWorld.submit(new Pulse(1, player) {
int counter;
@Override
public boolean pulse() {
switch (++counter) {
case 1:
final Location end = player.getLocation().transform(stone.getDirection(), -2);
final int hit = backwards ? 1 : 6;
if (set == BlockSets.FOUR) {
AgilityHandler.failWalk(player, 3, dest, end, AgilityPyramidCourse.transformLevel(end), Animation.create(1116), 10, hit, null);
} else {
AgilityHandler.failWalk(player, -1, dest, AgilityPyramidCourse.transformLevel(end), AgilityPyramidCourse.transformLevel(end), Animation.create(1116), 10, hit, null);
}
break;
case 3:
AgilityPyramidCourse.addConfig(player, stone, 0, true);
return true;
}
return false;
}
});
return false;
}
AgilityHandler.forceWalk(player, -1, dest, dest.transform(player.getDirection(), 2), Animation.create(1115), 20, 12, null);
GameWorld.submit(new Pulse(3, player) {
@Override
public boolean pulse() {
AgilityPyramidCourse.addConfig(player, stone, 0, true);
return true;
}
});
return false;
}
/**
* Checks if the player is going backwards.
* @param direction the object dir.
* @param dir the player dir.
* @param rotation the rotation of the object.
* @return {@code True} if so.
*/
public boolean isBackwards(Direction direction, Direction dir, int rot) {
switch (direction) {
case NORTH:
break;
case SOUTH:
return rot == 2 & dir == Direction.WEST;
case EAST:
return rot == 1 && dir == Direction.SOUTH;
case WEST:
return rot == 3 && dir == Direction.NORTH;
default:
break;
}
return false;
}
/**
* A block set.
* @author 'Vexia
*/
public enum BlockSets {
ONE(Location.create(3354, 2841, 0), Location.create(3354, 2842, 1), Location.create(3355, 2842, 1), Location.create(3355, 2841, 1), Location.create(3354, 2841, 1)), TWO(Location.create(3374, 2835, 0), Location.create(3374, 2835, 1), Location.create(3374, 2836, 1), Location.create(3375, 2836, 1), Location.create(3375, 2835, 1)), THREE(Location.create(3368, 2849, 1), Location.create(3368, 2849, 2), Location.create(3369, 2849, 2), Location.create(3369, 2850, 2), Location.create(3368, 2850, 2)), FOUR(Location.create(3048, 4699, 1), Location.create(3048, 4700, 2), Location.create(3049, 4700, 2), Location.create(3049, 4699, 2), Location.create(3048, 4699, 2)), FIVE(Location.create(3044, 4699, 2), Location.create(3044, 4700, 3), Location.create(3045, 4700, 3), Location.create(3045, 4699, 3), Location.create(3044, 4699, 3));
/**
* The block location.
*/
private final Location blockLocation;
/**
* The tile locations.
*/
private final Location[] tiles;
/**
* Constructs a new {@code BlockSets} {@code Object}.
* @param blockLocation the block location.
* @param tiles the tiles.
*/
private BlockSets(Location blockLocation, Location... tiles) {
this.blockLocation = blockLocation;
this.tiles = tiles;
}
/**
* Gets the set for the location.
* @param location the location.
* @return the block sets.
*/
public static BlockSets forLocation(Location location) {
for (BlockSets set : values()) {
for (Location loc : set.getTiles()) {
if (loc.equals(location)) {
return set;
}
}
}
return null;
}
/**
* Gets the blockLocation.
* @return The blockLocation.
*/
public Location getBlockLocation() {
return blockLocation;
}
/**
* Gets the tiles.
* @return The tiles.
*/
public Location[] getTiles() {
return tiles;
}
/**
* static-block to load block traps.
*/
static {
final RollingBlock block = new RollingBlock();
for (BlockSets set : values()) {
for (Location l : set.getTiles()) {
AgilityPyramidZone.LOCATION_TRAPS.put(l, block);
}
}
}
}
}

View file

@ -0,0 +1,57 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles the al kharid pit shortcut.
* @author adam
*/
@InitializablePlugin
public class AlKharidPitShortcut extends AgilityShortcut {
/**
* Represents the scaling down anmation.
*/
private static final Animation ANIMATION = new Animation(1148);
/**
* Represents the scaling animation.
*/
private static final Animation SCALE = new Animation(740);
/**
* Constructs a new {@Code AlKharidPitShortcut} {@Code Object}
*/
public AlKharidPitShortcut() {
super(new int[] { 9331, 9332 }, 38, 0.0, "climb");
}
@Override
public void run(Player player, GameObject object, String option, boolean failed) {
switch (object.getId()) {
case 9331:
ForceMovement.run(player, player.getLocation(), Location.create(3303, 3315, 0), ANIMATION, ANIMATION, Direction.EAST, 13).setEndAnimation(Animation.RESET);
break;
case 9332:
ForceMovement.run(player, player.getLocation(), Location.create(3307, 3315, 0), SCALE, SCALE, Direction.EAST, 13).setEndAnimation(Animation.RESET);
break;
}
}
@Override
public Location getDestination(Node node, Node n) {
final GameObject object = (GameObject) n;
if (object.getId() == 9331) {
return object.getLocation().transform(1, 0, 0);
}
return null;
}
}

View file

@ -0,0 +1,70 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the bar squeezing shortcut.
* @author Vexia
*/
@InitializablePlugin
public class BarSqueezeShortcut extends AgilityShortcut {
/**
* Constructs a new {@Code BarSqueezeShortcut} {@Code Object}
*/
public BarSqueezeShortcut() {
super(new int[] { 9334, 9337 }, 66, 1, "squeeze-through");
}
/**
* Constructs a new {@Code BarSqueezeShortcut} {@Code Object}
* @param ids the ids.
* @param level the level.
* @param exp the exp.
* @param option the option.
*/
public BarSqueezeShortcut(int[] ids, int level, double exp, String option) {
super(ids, level, exp, option);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
configure(new BarSqueezeShortcut(new int[] { 2186 }, 1, 0.0, "squeeze-through"));
return super.newInstance(arg);
}
@Override
public void run(Player player, GameObject object, String option, boolean failed) {
Direction dir = Direction.getLogicalDirection(player.getLocation(), object.getLocation());
Location start = player.getLocation();
if (object.getId() == 9334 && dir == Direction.NORTH) {
dir = Direction.WEST;
start = Location.create(3424, 3476, 0);
} else if (object.getId() == 9337 && dir == Direction.NORTH) {
dir = Direction.SOUTH;
if (player.getLocation().getY() < object.getLocation().getY()) {
dir = Direction.NORTH;
}
} else if (object.getId() == 2186 && player.getLocation().getY() >= 3161) {
dir = Direction.SOUTH;
}
AgilityHandler.forceWalk(player, -1, start, player.getLocation().transform(dir, 1), Animation.create(2240), 10, 0.0, null);
}
@Override
public boolean checkRequirements(Player player) {
if (!player.getQuestRepository().isComplete("Priest in Peril") && !(player.getLocation().getY() >= 3159 && player.getLocation().getY() <= 3161)) {
player.getDialogueInterpreter().sendDialogue("You need to have completed Priest in Peril in order to do this.");
return false;
}
return super.checkRequirements(player);
}
}

View file

@ -0,0 +1,36 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles a crumbling wall.
* @author Vexia
*/
@InitializablePlugin
public class CrumblingWallShortcut extends AgilityShortcut {
/**
* Represents the locations used in this force movement.
*/
private static final Location[] LOCATIONS = new Location[] { new Location(2936, 3355, 0), new Location(2934, 3355, 0) };
/**
* Constructs a new {@Code CrumblingWallShortcut} {@Code
* Object}
*/
public CrumblingWallShortcut() {
super(new int[] { 11844 }, 5, 0.0, "climb-over");
}
@Override
public void run(Player player, GameObject object, String option, boolean failed) {
ForceMovement.run(player, player.getLocation().getX() >= 2936 ? LOCATIONS[0] : LOCATIONS[1], player.getLocation().getX() >= 2936 ? LOCATIONS[1] : LOCATIONS[0], Animation.create(839), 10);
}
}

View file

@ -0,0 +1,67 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.diary.DiaryType;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles the fence jump shortcut.
* @author Vexia
*/
@InitializablePlugin
public class FenceJumpShortcut extends AgilityShortcut {
/**
* Represents the running animation.
*/
private static final Animation RUNNING_ANIM = new Animation(1995);
/**
* Represents the jumping animation.
*/
private static final Animation JUMP_ANIM = new Animation(1603);
/**
* Represents the related locations used in this shortcut. format: (start,
* start, end, end
*/
private static final Location[] LOCATIONS = new Location[] { new Location(3240, 3331, 0), new Location(3240, 3338, 0), Location.create(3240, 3334, 0), Location.create(3240, 3335, 0) };
/**
* Constructs a new {@Code FenceJumpShortcut} {@Code Object}
*/
public FenceJumpShortcut() {
super(new int[] { 9300 }, 13, 0.0, "jump-over");
}
@Override
public void run(final Player player, GameObject object, String option, boolean failed) {
player.faceLocation(object.getLocation());
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
player.animate(JUMP_ANIM);
if (!player.getAchievementDiaryManager().getDiary(DiaryType.VARROCK).isComplete(0, 5)) {
player.getAchievementDiaryManager().getDiary(DiaryType.VARROCK).updateTask(player, 0, 5, true);
}
return true;
}
});
ForceMovement.run(player, player.getLocation().getY() >= 3335 ? LOCATIONS[1] : LOCATIONS[0], player.getLocation().getY() >= 3335 ? LOCATIONS[2] : LOCATIONS[3], RUNNING_ANIM, 18);
}
@Override
public Location getDestination(Node node, Node n) {
Player player = node.asPlayer();
return player.getLocation().getY() >= 3335 ? LOCATIONS[1] : LOCATIONS[0];
}
}

View file

@ -0,0 +1,76 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the log balance shortcut.
* @author Vexia
*/
@InitializablePlugin
public class LogBalanceShortcut extends AgilityShortcut {
/**
* The start and ending location.
*/
private Location start;
/**
* The ending and start location.
*/
private Location end;
/**
* Constructs a new {@Code LogBalanceShortcut} {@Code Object}
* @param ids the ids.
* @param level the level.
* @param experience the experience.
* @param options the options.
*/
public LogBalanceShortcut(int[] ids, int level, double experience, Location start, Location end, String... options) {
super(ids, level, experience, options);
this.start = start;
this.end = end;
}
/**
* Constructs a new {@Code LogBalanceShortcut} {@Code Object}
*/
public LogBalanceShortcut() {
super(new int[] {}, 0, 0.0);
}
@Override
public Plugin<Object> newInstance(Object arg) {
configure(new LogBalanceShortcut(new int[] { 2296 }, 20, 5, new Location(2598, 3477, 0), Location.create(2603, 3477, 0), "walk-across"));
configure(new LogBalanceShortcut(new int[] { 9322, 9324 }, 48, 1, Location.create(2722, 3592, 0), Location.create(2722, 3596, 0), "walk-across"));
configure(new LogBalanceShortcut(new int[] { 35997, 35999 }, 33, 1, Location.create(2602, 3336, 0), Location.create(2598, 3336, 0), "walk-across"));
configure(new LogBalanceShortcut(new int[] { 2332 }, 1, 1, Location.create(2910, 3049, 0), Location.create(2906, 3049, 0), "cross"));
return this;
}
@Override
public void run(Player player, GameObject object, String option, boolean failed) {
Location destination = start;
if (player.getLocation().getDistance(start) < player.getLocation().getDistance(end)) {
destination = end;
}
AgilityHandler.walk(player, -1, player.getLocation(), destination, Animation.create(155), getExperience(), null);
}
@Override
public Location getDestination(Node node, Node n) {
if (node.getLocation().getDistance(start) < node.getLocation().getDistance(end)) {
return start;
}
return end;
}
}

View file

@ -0,0 +1,127 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.LocationLogoutTask;
import org.crandor.game.system.task.LogoutTask;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.tools.RandomFunction;
/**
* Handles the monkey bar shortcut.
* @author Vexia
*/
@InitializablePlugin
public class MonkeyBarShortcut extends AgilityShortcut {
/**
* Represents the location cache data for the monkey bars.
*/
private static final Location[][] MBAR_LOCATIONS = new Location[][] { { new Location(3120, 9969, 0), Location.create(3121, 9969, 0) }, { new Location(3119, 9969, 0), Location.create(3120, 9969, 0) }, { new Location(3120, 9964, 0), Location.create(3121, 9964, 0) }, { Location.create(3120, 9963, 0), Location.create(3120, 9964, 0) }, { new Location(2598, 9489, 0), new Location(2597, 9488, 0) }, { new Location(2598, 9489, 0), new Location(2600, 9488, 0) }, { new Location(2598, 9494, 0), new Location(2597, 9495, 0) }, { new Location(2599, 9494, 0), new Location(2600, 9495, 0) } };
/**
* Constructs a new {@Code MonkeyBarShortcut} {@Code Object}
*/
public MonkeyBarShortcut() {
super(new int[] { 29375 }, 1, 14.0, "swing across");
}
/**
* Constructs a new {@Code MonkeyBarShortcut} {@Code Object}
* @param ids the ids.
* @param level the level.
* @param experience the exp.
* @param option the option.
*/
public MonkeyBarShortcut(int[] ids, int level, double experience, String option) {
super(ids, level, experience, option);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
configure(new MonkeyBarShortcut(new int[] { 2321 }, 57, 20, "swing across"));
return super.newInstance(arg);
}
@Override
public void run(final Player player, final GameObject object, String option, boolean failed) {
player.lock(5);
Direction direct = Direction.get((object.getDirection().toInteger() + 2) % 4);
if (object.getId() == 29375) {
if (direct == Direction.SOUTH && player.getLocation().getY() < 9969) {
direct = Direction.NORTH;
} else if (direct == Direction.NORTH && player.getLocation().getY() >= 9969) {
direct = Direction.SOUTH;
}
} else if (object.getId() == 2321) {
if (player.getLocation().getY() >= 9494) {
direct = Direction.SOUTH;
} else {
direct = Direction.NORTH;
}
}
player.getAppearance().setAnimations(Animation.create(745));
final Location start = player.getLocation();
final Direction dir = direct;
ForceMovement.run(player, start.transform(dir), start.transform(dir.getStepX() << 1, dir.getStepY() << 1, 0), Animation.create(742), Animation.create(744));
player.addExtension(LogoutTask.class, new LocationLogoutTask(5, start));
GameWorld.submit(new Pulse(2, player) {
int count;
boolean failed;
@Override
public boolean pulse() {
if (++count == 1) {
if (object.getId() == 2321 && (failed = AgilityHandler.hasFailed(player, 57, 0.01))) {
setDelay(1);
player.animate(Animation.create(743));
return false;
}
setDelay(4);
AgilityHandler.walk(player, -1, player.getLocation().transform(dir), player.getLocation().transform(dir.getStepX() * 4, dir.getStepY() * 4, 0), Animation.create(662), 0.0, null);
player.addExtension(LogoutTask.class, new LocationLogoutTask(7, start));
} else if (count == 2) {
if (failed) {
player.getAppearance().setAnimations();
player.getAppearance().sync();
AgilityHandler.fail(player, 2, new Location(2599, 9564, 0), Animation.create(768), RandomFunction.random(1, 3), null);
return true;
}
AgilityHandler.forceWalk(player, -1, player.getLocation(), player.getLocation().transform(dir), Animation.create(743), 10, getExperience(), null);
return true;
}
return false;
}
});
}
@Override
public Location getDestination(Node n, Node node) {
if (node.getLocation().equals(new Location(2598, 9489, 0))) {
return new Location(2597, 9488, 0);
} else if (node.getLocation().equals(new Location(2598, 9494, 0))) {
return new Location(2597, 9495, 0);
} else if (node.getLocation().equals(new Location(2599, 9489, 0))) {
return new Location(2600, 9488, 0);
}
for (Location[] locations : MBAR_LOCATIONS) {
if (n.getLocation().equals(locations[0])) {
return locations[1];
}
}
if (node.getLocation().equals(new Location(2598, 9489, 0)) || node.getLocation().equals(new Location(2599, 9489, 0))) {
return new Location(2600, 9495, 0);
}
return null;
}
}

View file

@ -0,0 +1,89 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityHandler;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.diary.DiaryType;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles a pipe shortcut.
* @author Vexia
*/
@InitializablePlugin
public class PipeShortcut extends AgilityShortcut {
/**
* Constructs a new {@Code PipeShortcut} {@Code Object}
*/
public PipeShortcut() {
super(new int[] {}, 0, 0.0, "");
}
/**
* Constructs a new {@Code PipeShortcut} {@Code Object}
* @param ids the ids.
* @param level the level.
* @param experience the experience.
* @param options the options.
*/
public PipeShortcut(int[] ids, int level, double experience, String... options) {
super(ids, level, experience, options);
}
@Override
public Plugin<Object> newInstance(Object arg) {
configure(new PipeShortcut(new int[] { 9293 }, 70, 0.0, "squeeze-through"));
configure(new PipeShortcut(new int[] { 29370 }, 51, 0.0, "squeeze-through"));
configure(new PipeShortcut(new int[] { 2290 }, 49, 7.5, "squeeze-through"));
return this;
}
@Override
public void run(Player player, GameObject object, String option, boolean failed) {
Direction dir = getObjectDirection(object.getDirection());
if (object.getId() != 9293 && object.getId() != 2290) {
dir = dir.getOpposite();
}
int offset = 0;
if (object.getId() == 2290) {
offset = 1;
}
if (object.getId() == 29370 && !player.getAchievementDiaryManager().getDiary(DiaryType.VARROCK).isComplete(2, 5)) {
player.getAchievementDiaryManager().getDiary(DiaryType.VARROCK).updateTask(player, 2, 5, true);
}
final Location dest = player.getLocation().transform(dir, 3 + offset);
player.lock(5);
AgilityHandler.forceWalk(player, -1, player.getLocation(), dest, Animation.create(749), 10, 0, null);
AgilityHandler.forceWalk(player, -1, dest, dest.transform(dir, 2 + offset), Animation.create(844), 10, 0, null, 3);
AgilityHandler.forceWalk(player, 0, dest.transform(dir, 2), dest.transform(dir, 3), Animation.create(748), 20, getExperience(), null, 5);
}
@Override
public Location getDestination(Node n, Node node) {
Direction direction = getObjectDirection(node.asObject().getDirection());
boolean negative = direction == Direction.EAST;
int transform = 1;
if (negative) {
if (node.getId() == 9293) {
transform = -1;
} else {
transform = 2;
}
}
if (node.getId() == 9293 && direction == Direction.WEST) {
transform = -2;
} else if (node.getId() == 2290 && direction == Direction.WEST) {
transform = -2;
} else if (node.getId() == 2290 && direction == Direction.EAST) {
return new Location(2572, 9506, 0);
}
return node.getLocation().transform(direction, transform);
}
}

View file

@ -0,0 +1,59 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.diary.DiaryType;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles the rock climbing shortcut.
* @author Vexia
*/
@InitializablePlugin
public class RockClimbShortcut extends AgilityShortcut {
/**
* Represents the scaling down anmation.
*/
private static final Animation ANIMATION = new Animation(1148);
/**
* Represents the scaling animation.
*/
private static final Animation SCALE = new Animation(740);
/**
* Constructs a new {@Code RockClimbShortcut} {@Code Object}
*/
public RockClimbShortcut() {
super(new int[] { 9335, 9336, 2231 }, 1, 0.0, "climb");
}
@Override
public void run(Player player, GameObject object, String option, boolean failed) {
switch (object.getId()) {
case 2231:
if (player.getLocation().getX() <= 2791) {
ForceMovement.run(player, object.getLocation(), object.getLocation().transform(3, 0, 0), SCALE, SCALE, Direction.WEST, 13).setEndAnimation(Animation.RESET);
} else {
if (!player.getAchievementDiaryManager().hasCompletedTask(DiaryType.KARAMJA, 0, 5)) {
player.getAchievementDiaryManager().updateTask(player, DiaryType.KARAMJA, 0, 5, true);
}
ForceMovement.run(player, object.getLocation(), object.getLocation().transform(-3, 0, 0), ANIMATION, ANIMATION, Direction.WEST, 13).setEndAnimation(Animation.RESET);
}
break;
case 9335:
ForceMovement.run(player, player.getLocation(), Location.create(3427, 3478, 0), SCALE, SCALE, Direction.WEST, 13).setEndAnimation(Animation.RESET);
break;
case 9336:
ForceMovement.run(player, player.getLocation(), Location.create(3424, 3476, 0), ANIMATION, ANIMATION, Direction.WEST, 13).setEndAnimation(Animation.RESET);
break;
}
}
}

View file

@ -0,0 +1,52 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles the stepping stone shortcut.
* @author Vexia
*/
@InitializablePlugin
public class SteppingStoneShortcut extends AgilityShortcut {
/**
* Represents the animation to use.
*/
private static final Animation ANIMATION = new Animation(741);
/**
* Constructs a new {@Code SteppingStoneShortcut} {@Code
* Object}
*/
public SteppingStoneShortcut() {
super(new int[] { 9315 }, 1, 0.0, "jump-onto");
}
@Override
public void run(final Player player, GameObject object, String option, boolean failed) {
final int offset = player.getLocation().getX() == 3149 ? 1 : -1;
player.lock();
GameWorld.submit(new Pulse(2, player) {
int counter = 1;
@Override
public boolean pulse() {
if (counter == 6) {
player.unlock();
return true;
}
ForceMovement.run(player, player.getLocation(), player.getLocation().transform(offset, 0, 0), ANIMATION, 10);
counter++;
return false;
}
});
}
}

View file

@ -0,0 +1,107 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.activity.ActivityManager;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.interaction.MovementPulse;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles a stile shortcut.
* @author Vexia
*/
@InitializablePlugin
public class StileShortcut extends AgilityShortcut {
/**
* Constructs a new {@Code StileShortcut} {@Code Object}
*/
public StileShortcut() {
super(new int[] { 993, 3730, 7527, 12982, 19222, 22302, 29460, 33842, 34776 }, 1, 0.0, false, 0.0, new String[] { "climb-over" });
}
@Override
public void run(final Player player, final GameObject object, String option, boolean failed) {
player.getWalkingQueue().reset();
Location loc = getLocation(player, object, true);
player.getWalkingQueue().addPath(loc.getX(), loc.getY());
player.getPulseManager().run(new MovementPulse(player, loc) {
@Override
public boolean pulse() {
climb(player, object);
return true;
}
}, "movement");
}
/**
* Method used to climb the stile.
* @param player the player.
* @param object the object.
*/
public static void climb(final Player player, final GameObject object) {
player.lock(1);
int delay = 0;
GameWorld.submit(new Pulse(delay, player) {
@Override
public boolean pulse() {
ForceMovement movement = new ForceMovement(player, getLocation(player, object, true), getLocation(player, object, false), Animation.create(839)) {
@Override
public void stop() {
super.stop();
if (object.getId() == 19222) {// falconry.
handleFalconry(player, object);
}
}
};
movement.run(player, 5);
return true;
}
});
}
/**
* Method used to get the end location.
* @param player the player.
* @param object the object.
* @param start if getting the start loc.
* @return the location.
*/
public static Location getLocation(final Player player, final GameObject object, boolean start) {
if ((object.getDirection() == Direction.NORTH || object.getDirection() == Direction.SOUTH)) {
if (player.getLocation().getY() <= object.getLocation().getY()) {
return start ? object.getLocation() : object.getLocation().transform(0, 1, 0);
} else {
return start ? object.getLocation().transform(0, 1, 0) : object.getLocation();
}
} else {
if (player.getLocation().getX() <= object.getLocation().getX()) {
return start ? object.getLocation() : object.getLocation().transform(1, 0, 0);
} else {
return start ? object.getLocation().transform(1, 0, 0) : object.getLocation();
}
}
}
/**
* Method used to handle the falconry stile.
* @param player the player.
* @param object the object.
*/
private static void handleFalconry(final Player player, GameObject object) {
if (player.getLocation().equals(Location.create(2371, 3621, 0))) {
ActivityManager.start(player, "falconry", false);
} else {
ActivityManager.getActivity("falconry").leave(player, false);
}
}
}

View file

@ -0,0 +1,66 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles the strange floor shortcut.
* @author Vexia
*/
@InitializablePlugin
public class StrangeFloorShortcut extends AgilityShortcut {
/**
* Represents the running animation.
*/
private static final Animation RUNNING_ANIM = new Animation(1995);
/**
* Represents the jumping animation.
*/
private static final Animation JUMP_ANIM = new Animation(1603);
/**
* Constructs a new {@Code StrangeFloorShortcut} {@Code
* Object}
*/
public StrangeFloorShortcut() {
super(new int[] { 42334 }, 80, 0.0, "jump-over");
}
@Override
public void run(final Player player, GameObject object, String option, boolean failed) {
GameWorld.submit(new Pulse(1, player) {
@Override
public boolean pulse() {
player.getAnimator().forceAnimation(JUMP_ANIM);
return true;
}
});
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
player.getAnimator().forceAnimation(RUNNING_ANIM);
return true;
}
});
ForceMovement.run(player, player.getLocation().getX() >= 2880 ? Location.create(2881, 9813, 0) : Location.create(2877, 9813, 0), player.getLocation().getX() >= 2880 ? Location.create(2877, 9813, 0) : Location.create(2881, 9813, 0), RUNNING_ANIM, 13);
}
@Override
public Location getDestination(Node node, Node n) {
return node.getLocation().getX() >= 2880 ? Location.create(2881, 9813, 0) : Location.create(2877, 9813, 0);
}
}

View file

@ -0,0 +1,131 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles a tunnel shortcut.
* @author Vexia
*/
@InitializablePlugin
public class TunnelShortcut extends AgilityShortcut {
/**
* The climbing down animation.
*/
private static final Animation CLIMB_DOWN = Animation.create(2589);
/**
* The crawling through animation.
*/
private static final Animation CRAWL_THROUGH = Animation.create(2590);
/**
* The climbing up animation.
*/
private static final Animation CLIMB_UP = Animation.create(2591);
/**
* The increment offset.
*/
private int offset;
/**
* Constructs a new {@Code TunnelShortcut} {@Code Object}
*/
public TunnelShortcut() {
super(new int[] {}, 0, 0.0);
}
/**
* Constructs a new {@Code TunnelShortcut} {@Code Object}
* @param ids the ids.
* @param level the level.
* @param experience the experience.
* @param options the options.
*/
public TunnelShortcut(int[] ids, int level, double experience, int offset, String... options) {
super(ids, level, experience, options);
this.offset = offset;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
configure(new TunnelShortcut(new int[] { 9309, 9310 }, 26, 0.0, 0, "climb-into"));
configure(new TunnelShortcut(new int[] { 9302, 9301 }, 16, 0.0, 1, "climb-into", "climb-under"));
configure(new TunnelShortcut(new int[] { 14922 }, 1, 0.0, 1, "enter"));
return this;
}
@Override
public void run(final Player player, GameObject object, String option, boolean failed) {
player.lock(6);
final GameObject o = object;
final Location start = player.getLocation();
final Direction dir = Direction.getDirection(start, o.getLocation());
if (object.getLocation().getX() == 2575) {
offset = 1;
}
ForceMovement.run(player, start, o.getLocation(), CLIMB_DOWN, 8);
GameWorld.submit(new Pulse(1, player) {
int count;
@Override
public boolean pulse() {
switch (++count) {
case 2:
player.animate(CRAWL_THROUGH);
player.getProperties().setTeleportLocation(start.transform(dir, 2 + offset));
break;
case 5:
ForceMovement.run(player, player.getLocation(), start.transform(dir, 4 + offset), CLIMB_UP, 19);
break;
case 6:
player.animate(ForceMovement.WALK_ANIMATION);
return true;
}
return false;
}
});
}
@Override
public Location getDestination(Node node, Node n) {
if (n.getId() == 14922) {
return n.getLocation().transform(getObjectDirection(n.asObject().getDirection()), 1);
}
return getStart(n.getLocation(), n.getDirection());
}
/**
* Gets the start location.
* @param location the location.
* @param dir the dir.
* @return the location.
*/
public Location getStart(Location location, Direction dir) {
switch (dir) {
case NORTH:
break;
case SOUTH:
break;
case EAST:
return location.transform(0, location.getY() == 3111 ? 1 : -1, 0);
case WEST:
return location.transform(0, 1, 0);
default:
return location;
}
return location;
}
}

View file

@ -0,0 +1,42 @@
package plugin.skill.agility.shortcuts;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.agility.AgilityShortcut;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles the zanaris cosmic altar shortcuts for runecrafters.
* @author Splinter
*/
@InitializablePlugin
public class ZanarisSqueezeShortcut extends AgilityShortcut {
/**
* Represents the squeeze animation.
*/
private static final Animation ANIMATION = new Animation(2240);
/**
* Constructs a new {@Code ZanarisSqueezeShortcut} {@Code Object}
*/
public ZanarisSqueezeShortcut() {
super(new int[] { 12127 }, 46, 0.0, "squeeze-past");
}
@Override
public void run(Player player, GameObject object, String option, boolean failed) {
if (player.getSkills().getLevel(Skills.AGILITY) < 66 && (object.getLocation().equals(new Location(2408, 4395)) || object.getLocation().equals(new Location(2415, 4402)))) {
player.getDialogueInterpreter().sendDialogue("You need an Agility level of at least 66 to negotiate this obstacle.");
return;
}
Location to = player.getLocation().getY() < object.getLocation().getY() ? object.getLocation().transform(0, 1, 0) : object.getLocation().transform(0, -1, 0);
Direction dir = player.getLocation().getY() < object.getLocation().getY() ? Direction.NORTH : Direction.SOUTH;
ForceMovement.run(player, player.getLocation(), to, ANIMATION, ANIMATION, dir, 13).setEndAnimation(Animation.RESET);
}
}

View file

@ -0,0 +1,180 @@
package plugin.skill.construction;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.component.Component;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.skill.member.construction.*;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
/**
* The build option handling plugin.
* @author Emperor
*
*/
@InitializablePlugin
public final class BuildOptionPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.setOptionHandler("build", this);
ObjectDefinition.setOptionHandler("remove", this);
PluginManager.definePlugin(new RemoveDialogue());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
if (!player.getHouseManager().isBuildingMode()) {
player.getPacketDispatch().sendMessage("You have to be in building mode to do this.");
return true;
}
GameObject object = ((GameObject) node);
if (option.equals("remove")) {
Decoration decoration = Decoration.getDecoration(player, object);
if (decoration == null || !object.isActive()) {
return false;
}
player.getDialogueInterpreter().open("con:removedec", object);
return true;
}
player.setAttribute("con:hsobject", node);
if (BuildingUtils.isDoorHotspot(object)) {
int[] pos = BuildingUtils.roomExists(player, object);
if (pos != null) {
player.getDialogueInterpreter().open("con:remove", "room", pos);
return true;
}
if (player.getHouseManager().getRoomAmount() < player.getHouseManager().getMaximumRooms(player)) {
player.getInterfaceManager().open(new Component(402));
} else {
player.getPacketDispatch().sendMessage("You currently have the maximum amount of rooms available.");
}
return true;
}
Hotspot hotspot = player.getHouseManager().getHotspot(object);
if (hotspot == null || !isBuildable(player, object, hotspot)) {
System.out.println(hotspot == null);
System.err.println("Construction (building): " + hotspot + " : " + object);
return true;
}
player.setAttribute("con:hotspot", hotspot);
BuildingUtils.openBuildInterface(player, hotspot.getHotspot());
return true;
}
/**
* Checks if the hotspot can be used.
* @param player The player.
* @param hotspot The hotspot.
* @return {@code True} if so.
*/
private static boolean isBuildable(Player player, GameObject object, Hotspot hotspot) {
Room room = player.getHouseManager().getRoom(object.getLocation());
if (room == null) {
return false;
}
switch (hotspot.getHotspot()) {
case STAIRWAYS:
case STAIRS_DOWN:
case STAIRWAYS_DUNGEON:
if (room.isBuilt(BuildHotspot.HALL_RUG)) {
player.getPacketDispatch().sendMessage("You can't build a staircase on a rug.");
return false;
}
return true;
case HALL_RUG:
case HALL_RUG2:
case HALL_RUG3:
if (room.isBuilt(BuildHotspot.STAIRWAYS) || room.isBuilt(BuildHotspot.STAIRS_DOWN) || room.isBuilt(BuildHotspot.STAIRWAYS_DUNGEON)) {
player.getPacketDispatch().sendMessage("You can't build a rug under a staircase.");
return false;
}
return true;
case QUEST_STAIRWAYS:
case STAIRS_DOWN2:
if (room.isBuilt(BuildHotspot.Q_HALL_RUG)) {
player.getPacketDispatch().sendMessage("You can't build a staircase on a rug.");
return false;
}
return true;
case Q_HALL_RUG:
case Q_HALL_RUG2:
case Q_HALL_RUG3:
if (room.isBuilt(BuildHotspot.QUEST_STAIRWAYS) || room.isBuilt(BuildHotspot.STAIRS_DOWN2)) {
player.getPacketDispatch().sendMessage("You can't build a rug under a staircase.");
return false;
}
return true;
default:
return true;
}
}
/**
* Handles the removing a decoration dialogue.
* @author Emperor
*
*/
private static class RemoveDialogue extends DialoguePlugin {
/**
* The object.
*/
private GameObject object;
/**
* Constructs a new {@code RemoveDialogue} {@code Object}.
*/
public RemoveDialogue() {
super();
}
/**
* Constructs a new {@code RemoveDialogue} {@code Object}.
* @param player The player.
*/
public RemoveDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new RemoveDialogue(player);
}
@Override
public boolean open(Object... args) {
interpreter.sendOptions("Really remove it?", "Yes", "No");
object = (GameObject) args[0];
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (buttonId) {
case 1:
BuildingUtils.removeDecoration(player, object);
break;
}
end();
return true;
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("con:removedec") };
}
}
}

View file

@ -0,0 +1,267 @@
package plugin.skill.construction;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.construction.BuildingUtils;
import org.crandor.game.content.skill.member.construction.HouseManager;
import org.crandor.game.content.skill.member.construction.Room;
import org.crandor.game.content.skill.member.construction.RoomProperties;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.node.object.ObjectBuilder;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionChunk;
import org.crandor.plugin.InitializablePlugin;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/**
* Handles the building a room dialogue.
* @author Emperor
*
*/
@InitializablePlugin
public final class BuildRoomDialogue extends DialoguePlugin {
/**
* The door hotspot.
*/
private GameObject door;
/**
* The direction.
*/
private Direction[] directions;
/**
* The room exits.
*/
private boolean[] exits;
/**
* The rotation index.
*/
private int index;
/**
* The boundaries of the room to build.
*/
private List<GameObject> boundaries = new ArrayList<>();
/**
* The room we're building.
*/
private Room room;
/**
* The room x-coordinate.
*/
private int roomX;
/**
* The room y-coordinate.
*/
private int roomY;
/**
* The room z-coordinate (3 for dungeon).
*/
private int roomZ;
/**
* Constructs a new {@code BuildRoomDialogue} {@code Object}
*/
public BuildRoomDialogue() {
super();
}
/**
* Constructs a new {@code BuildRoomDialogue} {@code Object}
* @param player The player.
*/
public BuildRoomDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new BuildRoomDialogue(player);
}
@Override
public boolean open(Object... args) {
player.getInterfaceManager().close();
RoomProperties props = (RoomProperties) args[0];
if (player.getSkills().getStaticLevel(Skills.CONSTRUCTION) < props.getLevel()) {
interpreter.sendPlainMessage(false, "You need a Construction level of " + props.getLevel() + " to buy this room.");
stage = 2;
return true;
}
if (!player.getInventory().contains(995, props.getCost())) {
interpreter.sendPlainMessage(false, "You need " + props.getCost() + " coins to buy this room.");
stage = 2;
return true;
}
this.door = (GameObject) player.getAttribute("con:hsobject");
int[] pos = BuildingUtils.getRoomPosition(player, door);
roomX = pos[0];
roomY = pos[1];
if (!inBounds()) {
interpreter.sendPlainMessage(false, "Your house is too large. TODO: correct message");
stage = 2;
return true;
}
roomZ = player.getLocation().getZ();
if (roomZ != 0) {
Room r = player.getHouseManager().getRooms()[roomZ - 1][roomX][roomY];
if (r == null || r.getProperties().isLand()) {
interpreter.sendPlainMessage(false, "You can't build a room here, you need a room to build on.");
stage = 2;
return true;
}
}
if (HouseManager.isInDungeon(player)) {
if (props.isLand()) {
interpreter.sendPlainMessage(false, "You can't build this room inside your dungeon.");
stage = 2;
return true;
}
roomZ = 3;
}
else if (props.isDungeon()) {
interpreter.sendPlainMessage(false, "You can only build this room in your dungeon.");
stage = 2;
return true;
}
if (props.isLand() && roomZ != 0) {
interpreter.sendPlainMessage(false, "A garden can only be on ground floor.");
stage = 2;
return true;
}
this.room = Room.create(player, props);
this.exits = room.getExits(Direction.NORTH);
this.index = 0;
this.directions = BuildingUtils.getAvailableRotations(player, exits, roomZ, roomX, roomY);
while (directions[index] == null) {
if (++index == directions.length) {
interpreter.sendPlainMessage(false, "There's no space to build this room.");
stage = 2;
return true;
}
}
options("Rotate clockwise", "Rotate anticlockwise", "Build", "Cancel");
stage = 1;
drawGhostRoom();
return true;
}
/**
* Checks if the room to be built is in the available boundaries of the house.
* @return The boundaries.
*/
private boolean inBounds() {
Rectangle bounds = player.getHouseManager().getBoundaries();
int max = player.getHouseManager().getMaximumDimension(player);
if ((roomX < bounds.x || roomX >= bounds.x + bounds.width) && bounds.width >= max) {
return false;
}
if ((roomY < bounds.y || roomY >= bounds.y + bounds.height) && bounds.height >= max) {
return false;
}
return true;
}
@Override
public boolean close() {
for (GameObject object : boundaries) {
ObjectBuilder.remove(object);
}
boundaries.clear();
return super.close();
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 1:
switch (buttonId) {
case 1:
case 2:
rotate(buttonId == 2);
options("Rotate clockwise", "Rotate anticlockwise", "Build", "Cancel");
return true;
case 3:
if (player.getInventory().remove(new Item(995, room.getProperties().getCost()))) {
room.setRotation(directions[index]);
boolean[] exit = new boolean[exits.length];
for (int i = 0; i < exit.length; i++) {
exit[(i + index) % exit.length] = exits[i];
}
BuildingUtils.buildRoom(player, room, roomZ, roomX, roomY, exit, true);
end();
return true;
}
interpreter.sendPlainMessage(false, "You need " + room.getProperties().getCost() + " coins to buy this room.");
stage = 2;
return true;
case 4:
end();
return true;
}
break;
case 2:
end();
return true;
}
return false;
}
/**
* Rotates the room.
* @param counter If we're rotating counter clockwise.
*/
private void rotate(boolean counter) {
Direction direction = null;
while ((direction = directions[index = (index + (counter ? 3 : 1)) % 4]) == null) {
}
room.setRotation(direction);
drawGhostRoom();
}
/**
* Draws the current boundaries of the room to build.
*/
private void drawGhostRoom() {
for (GameObject object : boundaries) {
ObjectBuilder.remove(object);
}
int rotation = directions[index].toInteger();
boundaries.clear();
Location base = player.getViewport().getRegion().getBaseLocation().transform(roomX << 3, roomY << 3, player.getLocation().getZ());
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
GameObject[] objects = room.getChunk().getObjects(x, y);
for (GameObject object : objects) {
if (object != null && object.getDefinition().hasAction("build")) {
int[] pos = RegionChunk.getRotatedPosition(x, y, object.getDefinition().getSizeX(), object.getDefinition().getSizeY(), object.getRotation(), rotation);
GameObject obj = object.transform(object.getId(), (object.getRotation() + rotation) % 4, base.transform(pos[0], pos[1], 0));
boundaries.add(ObjectBuilder.add(obj));
}
}
}
}
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("con:room") };
}
}

View file

@ -0,0 +1,104 @@
package plugin.skill.construction;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.dialogue.book.Book;
import org.crandor.game.content.dialogue.book.Page;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.GameWorld;
import org.crandor.plugin.InitializablePlugin;
/**
* Handles the construction guide book.
* @author Emperor
*
*/
@InitializablePlugin
public class ConstructionGuideBook extends Book {
/**
* The resources used in beta.
*/
private static final Item[] RESOURCES = {
new Item(8794),
new Item(2347),
new Item(4819, 500000),
new Item(4820, 500000),
new Item(1539, 500000),
new Item(4821, 500000),
new Item(4822, 500000),
new Item(4823, 500000),
new Item(4824, 500000),
new Item(961, 500000),
new Item(8779, 500000),
new Item(8781, 500000),
new Item(8783, 500000),
new Item(8791, 500000),
new Item(8785, 500000),
new Item(8787, 500000),
new Item(8789, 500000), //16
new Item(8418, 500000),
new Item(8420, 500000),
new Item(8422, 500000),
new Item(8424, 500000),
new Item(8426, 500000),
new Item(8428, 500000),
new Item(8430, 500000),
new Item(8432, 500000),
new Item(8434, 500000),
new Item(8436, 500000),
};
/**
* Constructs a new {@code ConstructionGuideBook} {@code Object}.
*/
public ConstructionGuideBook() {
/*
* empty.
*/
}
/**
* Constructs a new {@code ConstructionGuideBook} {@code Object}.
* @param player
*/
public ConstructionGuideBook(Player player) {
super(player, "Construction guide book", DialogueInterpreter.getDialogueKey("book:conguide"));
}
@Override
public boolean open(final Player player) {
if (GameWorld.getSettings().isDevMode() && GameWorld.getSettings().isBeta()) {
for (Item item : RESOURCES) {
if (!player.getInventory().contains(item.getId(), item.getAmount())) {
player.getInventory().add(item, player);
}
}
}
interpreter.sendPlainMessage(false, "Upon reading the book you discover you're supposed to", "use these resources to test out construction.", "Report all bugs on the forums.");
return true;
}
@Override
public void finish() {
}
@Override
public void display(Page[] set) {
}
@Override
public DialoguePlugin newInstance(Player player) {
return new ConstructionGuideBook(player);
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("book:conguide") };
}
}

View file

@ -0,0 +1,117 @@
package plugin.skill.construction;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.construction.*;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the creating of a decoration object.
* @author Emperor
*
*/
@InitializablePlugin
public final class ConstructionInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(396, this);
ComponentDefinition.put(398, this);
ComponentDefinition.put(402, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
switch (component.getId()) {
case 396:
switch (button) {
case 11:
player.getInterfaceManager().close();
Hotspot hotspot = player.getAttribute("con:hotspot");
GameObject object = player.getAttribute("con:hsobject");
if (hotspot == null || object == null) {
System.err.println("Failed building decoration " + hotspot + " : " + object);
break;
}
slot = ((slot % 2 != 0) ? 4 : 0) + (slot >> 1);
if (slot >= hotspot.getHotspot().getDecorations().length) {
System.err.println("Failed building decoration " + slot + "/" + hotspot.getHotspot().getDecorations().length);
break;
}
boolean debug = player.isStaff();
Decoration deco = hotspot.getHotspot().getDecorations()[slot];
if (!debug) {
if (player.getSkills().getLevel(Skills.CONSTRUCTION) < deco.getLevel()) {
player.getPacketDispatch().sendMessage("You need to have a Construction level of " + deco.getLevel() + " to build that.");
return true;
}
if (!player.getInventory().containsItems(deco.getItems())) {
player.getPacketDispatch().sendMessage("You don't have the right materials.");
return true;
}
for (int tool : deco.getTools()) {
if (tool == BuildingUtils.WATERING_CAN) {
boolean hasWateringCan = false;
for (int i = 0; i < 8; i++) {
if (player.getInventory().contains(tool - i, 1)) {
hasWateringCan = true;
break;
}
}
if (!hasWateringCan) {
player.getPacketDispatch().sendMessage("You need a watering can to plant this.");
return true;
}
continue;
}
if (!player.getInventory().contains(tool, 1)) {
player.getPacketDispatch().sendMessage("You need a " + ItemDefinition.forId(tool).getName() + " to build this.");
return true;
}
}
}
BuildingUtils.buildDecoration(player, hotspot, deco, object);
return true;
}
break;
case 398:
switch (button) {
case 15:
player.getHouseManager().toggleBuildingMode(player, true);
return true;
case 1:
player.getHouseManager().toggleBuildingMode(player, false);
return true;
case 27:
player.getHouseManager().expelGuests(player);
return true;
case 29:
if (!player.getHouseManager().isInHouse(player)) {
player.getPacketDispatch().sendMessage("You can't do this outside of your house.");
return true;
}
HouseManager.leave(player);
return true;
}
break;
case 402:
int index = button - 160;
//System.err.println("BuildRoom Interface Index: " + index);
if (index > -1 && index < RoomProperties.values().length) {
player.getDialogueInterpreter().open("con:room", RoomProperties.values()[index]);
return true;
}
break;
}
return false;
}
}

View file

@ -0,0 +1,318 @@
package plugin.skill.construction;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.dialogue.FacialExpression;
import org.crandor.game.content.global.Skillcape;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.construction.HouseLocation;
import org.crandor.game.content.skill.member.construction.HousingStyle;
import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
/**
* Represents the estate agent dialogue.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class EstateAgentDialogue extends DialoguePlugin {
/**
* Represents the book item.
*/
private static final Item BOOK = new Item(8463, 1);
/**
* Constructs a new {@code EstateAgentDialogue} {@code Object}.
*/
public EstateAgentDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code EstateAgentDialogue} {@code Object}.
* @param player the player.
*/
public EstateAgentDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new EstateAgentDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Hello. Welcome to the " + GameWorld.getName() + " Housing Agency! What", "can I do for you?");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
if (player.getHouseManager().hasHouse()) {
interpreter.sendOptions("Select an Option", "Can you move my house please?", "Can you redecorate my house please?", "Could I have a Construction guidebook?", "Tell me about houses.", "Tell me about that skillcape you're wearing.");
stage = 1;
} else {
interpreter.sendOptions("Select an Option", "How can I get a house?", "Tell me about houses.");
stage = 2;
}
break;
case 1:
switch (buttonId) {
case 1:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Can you move my house please?");
stage = 10;
break;
case 2:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Can you redecorate my house please?");
stage = 30;
break;
case 3:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Could I have a Construction guidebook?");
stage = 60;
break;
case 4:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Tell me about houses!");
stage = 90;
break;
case 5:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Tell me about that skillcape you're wearing!");
stage = Skillcape.isMaster(player, Skills.CONSTRUCTION) ? 102 : 100;
break;
}
break;
case 2:
switch (buttonId) {
case 1:
player("How can I get a house?");
stage = 3;
break;
case 2:
player("Tell me about houses.");
stage = 90;
break;
}
break;
case 3:
npc("I can sell you a starting house in Rimmington for", "1000 coins. As you increase your construction skill you", "will be able to have your house moved to other areas", "and redecorated in other styles.");
stage = 4;
break;
case 4:
npc("Do you want to buy a starter house?");
stage = 5;
break;
case 5:
options("Yes please!", "No thanks.");
stage = 6;
break;
case 6:
switch (buttonId) {
case 1:
player("Yes please!");
stage = 7;
break;
case 2:
player("No thanks.");
stage = 150;
break;
}
break;
case 7:
if (player.getInventory().contains(995, 1000)) {
player.getInventory().remove(new Item(995, 1000));
player.getHouseManager().create(HouseLocation.RIMMINGTON);
npc("Thank you. Go through the Rimmington house portal", "and you will find your house ready for you to start", "building in it.");
stage = 150;
} else {
npc("You don't have enough money to buy a house,", "come back when you can afford one.");
stage = 150;
}
break;
case 8:
if (GameWorld.getSettings().isDevMode() && GameWorld.getSettings().isBeta()) {
npc("This book will help you to start building your house.", "When you open the book you will receive some", "Construction resources.");
} else {
npc("This book will help you to start building your house.");
}
player.getInventory().add(BOOK);
stage = 150;
break;
case 10:
//HouseLocation.HOUSE_OPTIONS.open(player);
end();
break;
case 30:
npc("Certainly. My magic can rebuild the house in a", "completely new style! What style would you like?");
stage = 31;
break;
case 31:
options("Basic wood (5,000)", "Basic stone (5,000)", "Whitewashed stone (7,500)", "Fremennik-style wood (10,000)", "More...");
stage = 32;
break;
case 32:
switch (buttonId) {
case 1:
player("Basic wood please!");
stage = 33;
break;
case 2:
player("Basic stone please!");
stage = 34;
break;
case 3:
player("Whitewashed stone please!");
stage = 35;
break;
case 4:
player("Fremennik-style wood please!");
stage = 36;
break;
case 5:
options("Tropical wood (15,000)", "Fancy stone (25,000)", "Previous...");
stage = 39;
break;
}
break;
case 33:
redecorate(HousingStyle.BASIC_WOOD);
break;
case 34:
redecorate(HousingStyle.BASIC_STONE);
break;
case 35:
redecorate(HousingStyle.WHITEWASHED_STONE);
break;
case 36:
redecorate(HousingStyle.FREMENNIK_STYLE_WOOD);
break;
case 37:
redecorate(HousingStyle.TROPICAL_WOOD);
break;
case 38:
redecorate(HousingStyle.FANCY_STONE);
break;
case 39:
switch (buttonId) {
case 1:
player("Tropical wood please!");
stage = 37;
break;
case 2:
player("Fancy stone please!");
stage = 38;
break;
case 3:
options("Basic wood (5,000)", "Basic stone (5,000)", "Whitewashed stone (7,500)", "Fremennik-style wood (10,000)", "More...");
stage = 32;
break;
}
break;
case 60:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Certainly.");
player.getInventory().add(BOOK);
stage = 150;
break;
case 90:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "It all came out of the wizards' experiments. They found", "a way to fold space, so that they could pack many", "acres of land into an area only a foot across.");
stage = 91;
break;
case 91:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "They created several folded-space regions across", "" + GameWorld.getName() + ". Each one contains hundreds of small plots", "where people can build houses.");
stage = 92;
break;
case 92:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Ah, so that's how everyone can have a house without", "them cluttering up the world!");
stage = 93;
break;
case 93:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Quite. The wizards didn't want to get bogged down", "in the business side of things so they ", "hired me to sell the houses.");
stage = 94;
break;
case 94:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "There are various other people across " + GameWorld.getName() + " who can", "help you furnish your house. You should start buying", "planks from the sawmill operator in Varrock.");
stage = 150;
break;
case 100:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "As you may know, skillcapes are only available to masters", "in a skill. I have spent my entire life building houses and", "now I spend my time selling them! As a sign of my abilites", "I wear this Skillcape of Construction. If you ever have");
stage = 101;
break;
case 101:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "enough skill to build a demonic throne, come and talk to", "me and I'll sell you a skillcape like mine.");
stage = 150;
break;
case 102:
interpreter.sendDialogues(npc, FacialExpression.HAPPY, "I see you have recently achieved 99 construction.", "Would you like to buy a cape for 99,0000 gp?");
stage = 103;
break;
case 103:
interpreter.sendOptions("Select an Option", "Yes, I'll pay the 99k", "No thanks, maybe later.");
stage = 104;
break;
case 104:
switch (buttonId) {
case 1:
if (Skillcape.purchase(player, Skills.CONSTRUCTION)) {
npc("Here you go lad, enjoy!");
}
stage = 150;
break;
case 2:
stage = 150;
break;
}
break;
case 150:
end();
break;
}
return true;
}
/**
* Redecorates the player's house.
* @param style The house style.
*/
private void redecorate(HousingStyle style) {
boolean diary = false;//player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR).isComplete(0);
if (style == player.getHouseManager().getStyle()) {
npc("Your house is already in that style!");
stage = 31;
return;
}
if (style.getLevel() > player.getSkills().getStaticLevel(Skills.CONSTRUCTION)) {
npc("You need a Construction level of " + style.getLevel() + " to buy this style.");
stage = 31;
return;
}
if (!player.getInventory().contains(995, style.getCost()) && !diary) {
npc("Hmph. Come back when you have " + style.getCost() + " coins.");
stage = 150;
return;
}
if (!diary) {
player.getInventory().remove(new Item(995, style.getCost()));
}
player.getHouseManager().redecorate(style);
npc("Your house has been redecorated.");
if (player.getLocation().withinDistance(new Location(2982, 3370))) {
//player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR).updateTask(player, 1, 5, true);
}
stage = 150;
}
@Override
public int[] getIds() {
return new int[] { 4247 };
}
}

View file

@ -0,0 +1,153 @@
package plugin.skill.construction;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.skill.member.construction.HouseLocation;
import org.crandor.game.content.skill.member.construction.HouseManager;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.repository.Repository;
import org.crandor.plugin.*;
/**
* Handles the house portal options.
* @author Emperor
*
*/
@InitializablePlugin
public final class PortalOptionPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (HouseLocation hl : HouseLocation.values()) {
ObjectDefinition.forId(hl.getPortalId()).getConfigurations().put("option:enter", this);
}
ObjectDefinition.forId(13405).getConfigurations().put("option:lock", this);
ObjectDefinition.forId(13405).getConfigurations().put("option:enter", this);
PluginManager.definePlugin(new PortalDialogue());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
GameObject object = node.asObject();
if (object.getId() == 13405 && option.equals("enter")) {
HouseManager.leave(player);
return true;
}
if (option.equals("lock")) {
if (player.getHouseManager().isInHouse(player)) {
player.getHouseManager().setLocked(player.getHouseManager().isLocked() ? false : true);
player.sendMessage("Your house is now "+(player.getHouseManager().isLocked() ? "locked." : "unlocked." ));
return true;
}
player.sendMessage("This is not your house.");
return true;
}
player.setAttribute("con:portal", object.getId());
player.getDialogueInterpreter().open("con:portal");
return true;
}
/**
* Handles the portal dialogue.
* @author Emperor
*/
@PluginManifest(type= PluginType.DIALOGUE)
private class PortalDialogue extends DialoguePlugin {
/**
* Constructs a new {@code PortalDialogue} {@code Object}
*/
public PortalDialogue() {
}
/**
* Constructs a new {@code PortalDialogue} {@code Object}
* @param player The player.
*/
public PortalDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new PortalDialogue(player);
}
@Override
public boolean open(Object... args) {
options("Go to your house", "Go to your house (building mode)", "Go to a friend's house", "Never mind");
stage = 1;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
end();
switch (stage) {
case 1:
switch (buttonId) {
case 1:
case 2:
if (!player.getHouseManager().hasHouse()) {
player.getPacketDispatch().sendMessage("<col=FF0000>You don't have a house, talk to an estate agent to purchase a house.");
break;
}
if (player.getHouseManager().getLocation().getPortalId() != player.getAttribute("con:portal", -1)) {
player.getPacketDispatch().sendMessage("<col=FF0000>Your house is in " + player.getHouseManager().getLocation().name().toLowerCase() + ".");
player.sendMessage("<col=FF0000>Speak with an estate agent to change your house location.");
break;
}
player.getHouseManager().enter(player, buttonId == 2, true);
break;
case 3:
player.getDialogueInterpreter().sendInput(true, "Enter friend's name:");
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
Player p = Repository.getPlayerByName((String) getValue());
if (p == null || !p.isActive()) {
player.getPacketDispatch().sendMessage("This player is not online.");
return true;
}
if (p.getUsername().equals(player.getUsername())) {
player.getPacketDispatch().sendMessage("You aren't a friend of yourself!");
return true;
}
if (!p.getHouseManager().isLoaded()) {
player.getPacketDispatch().sendMessage("This player is not at home right now.");
return true;
}
if (p.getHouseManager().isBuildingMode()) {
player.getPacketDispatch().sendMessage("This player is in building mode.");
return true;
}
if (p.getHouseManager().isLocked()) {
player.getPacketDispatch().sendMessage("The other player has locked their house.");
return true;
}
p.setAttribute("poh_owner", getValue());
p.getHouseManager().enter(player, false, false);
return true;
}
});
break;
}
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("con:portal") };
}
}
}

View file

@ -0,0 +1,105 @@
package plugin.skill.construction;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.skill.member.construction.Hotspot;
import org.crandor.game.content.skill.member.construction.HouseManager;
import org.crandor.game.content.skill.member.construction.Room;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
/**
* Removal dialogue for room & decorations in construction
* @author Clayton Williams
* @author Emperor
* @date Jun-30-2015
*/
@InitializablePlugin
public final class RemovalDialogue extends DialoguePlugin {
/**
* The room position.
*/
private int[] pos;
/**
* The plane.
*/
private int plane;
/**
* The room to remove.
*/
private Room room;
/**
* Removal Dialogue
*/
public RemovalDialogue() {
super();
}
/**
* Removal Dialogue
* @param player
*/
public RemovalDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new RemovalDialogue(player);
}
@Override
public boolean open(Object... args) {
pos = (int[]) args[1];
plane = player.getLocation().getZ();
if (HouseManager.isInDungeon(player)) {
plane = 3;
}
room = player.getHouseManager().getRooms()[plane][pos[0]][pos[1]];
player.getDialogueInterpreter().sendOptions("Remove the " + (room != null ? room.getProperties().getName() : "room") + "?", "Yes", "No");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
if (stage == 0) {
if (buttonId == 1) {
if (plane == 0 && player.getHouseManager().hasRoom(1, pos[0], pos[1])) {
interpreter.sendPlainMessage(false, "You can't remove a room supporting another room.");
stage = 1;
return true;
}
if (room != null && room.getProperties().isLand()) {
Hotspot h = room.getHotspots()[0];
if (h != null && h.getDecorationIndex() == 0 && player.getHouseManager().getPortalAmount() <= 1) {
interpreter.sendPlainMessage(false, "You can't remove the garden with your portal in it.");
stage = 1;
return true;
}
}
player.getHouseManager().getRooms()[plane][pos[0]][pos[1]] = null;
for (int i = plane; i < 3; i++) {
Room r = player.getHouseManager().getRooms()[i][pos[0]][pos[1]];
if (r != null && r.getProperties().isRoof()) {
player.getHouseManager().getRooms()[i][pos[0]][pos[1]] = null;
}
}
player.getHouseManager().reload(player, true);
}
}
end();
return true;
}
@Override
public int[] getIds() {
return new int[]{ DialogueInterpreter.getDialogueKey("con:remove") };
}
}

View file

@ -0,0 +1,75 @@
package plugin.skill.construction.decoration;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the Construction beer barrels.
* @author Splinter
*/
@InitializablePlugin
public class BeerBarrelPlugin extends UseWithHandler {
/**
* The object ids
*/
private static final int[] OBJECTS = new int[] {
13568, 13569, 13570, 13571, 13572, 13573
};
/**
* Constructs a new {@Code BeerBarrelPlugin} {@Code Object}
*/
public BeerBarrelPlugin() {
super(1919);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int id : OBJECTS) {
addHandler(id, OBJECT_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
Player player = event.getPlayer();
final GameObject object = (GameObject) event.getUsedWith();
if (player.getInventory().remove(new Item(1919))) {
player.animate(Animation.create(833));
player.sendMessage("You fill up your glass.");
player.getInventory().add(new Item(getReward(object.getId()), 1));
}
return true;
}
/**
* Get the beer reward based on the interaced barrel.
* @return the item to give.
*/
public int getReward(int barrelId) {
switch (barrelId) {
case 13568:
return 1917;
case 13569:
return 5763;
case 13570:
return 1905;
case 13571:
return 1909;
case 13572:
return 1911;
case 13573:
return 5755;
}
return 1917;
}
}

View file

@ -0,0 +1,97 @@
package plugin.skill.construction.decoration;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.skill.member.construction.Decoration;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles chair and bench options.
* @author Emperor
*
*/
@InitializablePlugin
public final class ChairBenchPlugin extends OptionHandler {
/**
* The decorations that can be seated on.
*/
private static final Object[][] CHAIRS = {
{Decoration.CRUDE_CHAIR, 4073, 4103},
{Decoration.WOODEN_CHAIR, 4075, 4103},
{Decoration.ROCKING_CHAIR, 4079, 4103},
{Decoration.OAK_CHAIR, 4081, 4103},
{Decoration.OAK_ARMCHAIR, 4083, 4103},
{Decoration.TEAK_ARMCHAIR, 4085, 4103},
{Decoration.MAHOGANY_ARMCHAIR, 4087, 4103},
{Decoration.BENCH_WOODEN, 4089, 4104},
{Decoration.BENCH_OAK, 4091, 4104},
{Decoration.BENCH_CARVED_OAK, 4093, 4104},
{Decoration.BENCH_TEAK, 4095, 4104},
{Decoration.BENCH_CARVED_TEAK, 4097, 4104},
{Decoration.BENCH_MAHOGANY, 4099, 4104},
{Decoration.BENCH_GILDED, 4101, 4104},
{Decoration.CARVED_TEAK_BENCH, 4097, 4104},
{Decoration.MAHOGANY_BENCH, 4099, 4104},
{Decoration.GILDED_BENCH, 4101, 4104},
{Decoration.OAK_THRONE, 4111, 4103},
{Decoration.TEAK_THRONE, 4112, 4103},
{Decoration.MAHOGANY_THRONE, 4113, 4103},
{Decoration.GILDED_THRONE, 4114, 4103},
{Decoration.SKELETON_THRONE, 4115, 4103},
{Decoration.CRYSTAL_THRONE, 4116, 4103},
{Decoration.DEMONIC_THRONE, 4117, 4103},
};
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Object[] data : CHAIRS) {
ObjectDefinition.forId(((Decoration) data[0]).getObjectId()).getConfigurations().put("option:sit-on", this);
}
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
GameObject object = (GameObject) node;
int animId = -1;
int sitAnimId = -1;
for (Object[] data : CHAIRS) {
if (((Decoration) data[0]).getObjectId() == object.getId()) {
animId = (Integer) data[1];
sitAnimId = (Integer) data[2];
break;
}
}
if (object.getType() == 11) {
animId++;
}
final int animation = animId;
final int sitAnimation = sitAnimId;
ForceMovement.run(player, player.getLocation(), node.getLocation(), ForceMovement.WALK_ANIMATION, Animation.create(sitAnimation), object.getDirection().getOpposite(), ForceMovement.WALKING_SPEED, ForceMovement.WALKING_SPEED);
player.getLocks().lockInteractions(600000);
player.getPulseManager().run(new Pulse(2) {
@Override
public boolean pulse() {
player.animate(Animation.create(animation));
return false;
}
@Override
public void stop() {
super.stop();
player.getLocks().unlockInteraction();
player.animate(Animation.create(sitAnimation + 2));
}
});
return true;
}
}

View file

@ -0,0 +1,88 @@
package plugin.skill.construction.decoration;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.DoorActionHandler;
import org.crandor.game.content.skill.member.construction.BuildHotspot;
import org.crandor.game.content.skill.member.construction.Decoration;
import org.crandor.game.content.skill.member.construction.HousingStyle;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles Construction related doors.
* @author Emperor
*
*/
@InitializablePlugin
public final class ConstructionDoorPlugin extends OptionHandler {
/**
* The replacement ids.
*/
private static int[][] REPLACEMENT = {
{ 13100, 13102 },
{ 13101, 13103 },
{ 13094, 13095 },
{ 13096, 13097 },
{ 13006, 13008 },
{ 13007, 13008 },
{ 13109, 13110 },
{ 13107, 13108 },
{ 13016, 13018 },
{ 13015, 13017 },
{ 13119, 13121 },
{ 13118, 13120 },
};
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (HousingStyle style : HousingStyle.values()) {
ObjectDefinition.forId(style.getDoorId()).getConfigurations().put("option:open", this);
ObjectDefinition.forId(style.getSecondDoorId()).getConfigurations().put("option:open", this);
}
for (Decoration deco : BuildHotspot.DUNGEON_DOOR_LEFT.getDecorations()) {
ObjectDefinition.forId(deco.getObjectId()).getConfigurations().put("option:open", this);
ObjectDefinition.forId(deco.getObjectId()).getConfigurations().put("option:pick-lock", this);
ObjectDefinition.forId(deco.getObjectId()).getConfigurations().put("option:force", this);
}
for (Decoration deco : BuildHotspot.DUNGEON_DOOR_RIGHT.getDecorations()) {
ObjectDefinition.forId(deco.getObjectId()).getConfigurations().put("option:open", this);
ObjectDefinition.forId(deco.getObjectId()).getConfigurations().put("option:pick-lock", this);
ObjectDefinition.forId(deco.getObjectId()).getConfigurations().put("option:force", this);
}
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
GameObject object = (GameObject) node;
GameObject second = DoorActionHandler.getSecondDoor(object, player);
switch (option) {
case "pick-lock":
case "force":
return false; //TODO
}
DoorActionHandler.open(object, second, getReplaceId(object), getReplaceId(second), true, 500, false);
return true;
}
/**
* Gets the replace id for the door.
* @param object The door.
* @return The replace object id.
*/
private int getReplaceId(GameObject object) {
for (int[] data : REPLACEMENT) {
if (object.getId() == data[0]) {
return data[1];
}
}
return object.getId() + 6;
}
}

View file

@ -0,0 +1,63 @@
package plugin.skill.construction.decoration;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.node.object.ObjectBuilder;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the various fireplaces that you may light in Construction.
* @author Splinter
* @author Emperor
*/
@InitializablePlugin
public final class FireplacePlugin extends OptionHandler {
/**
* The animation.
*/
private static final Animation ANIMATION = Animation.create(3658);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(13609).getConfigurations().put("option:light", this);
ObjectDefinition.forId(13611).getConfigurations().put("option:light", this);
ObjectDefinition.forId(13613).getConfigurations().put("option:light", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
if (!player.getInventory().contains(1511, 1) || !player.getInventory().contains(590, 1)) {
player.sendMessage("You need some logs and a tinderbox in order to light the fireplace.");
return true;
}
final GameObject obj = (GameObject) node.asObject();
player.lock(2);
player.animate(ANIMATION);
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
if (!obj.isActive()) {
return true;
}
player.getInventory().remove(new Item(1511));
player.getSkills().addExperience(Skills.FIREMAKING, 80);
ObjectBuilder.replace(new GameObject(obj.getId(), obj.getLocation()), new GameObject(obj.getId() + 1, obj.getLocation(), obj.getRotation()), 1000);
player.sendMessage("You light the fireplace.");
return true;
}
});
return true;
}
}

View file

@ -0,0 +1,439 @@
package plugin.skill.construction.decoration;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.skill.member.construction.*;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.node.object.ObjectBuilder;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
/**
* Handles construction staircases.
* @author Emperor
*
*/
@InitializablePlugin
public final class StaircasePlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
PluginManager.definePlugin(new BuildDialogue());
PluginManager.definePlugin(new ClimbPohLadder());
for (int i = 13497; i < 13507; i++) {
ObjectDefinition.forId(i).getConfigurations().put("option:climb", this);
ObjectDefinition.forId(i).getConfigurations().put("option:climb-up", this);
ObjectDefinition.forId(i).getConfigurations().put("option:climb-down", this);
ObjectDefinition.forId(i).getConfigurations().put("option:remove-room", this);
}
ObjectDefinition.forId(13409).getConfigurations().put("option:enter", this);
ObjectDefinition.forId(13409).getConfigurations().put("option:remove-room", this);
for (int id = 13328; id < 13331; id++) {
ObjectDefinition.forId(id).getConfigurations().put("option:climb", this);
ObjectDefinition.forId(id).getConfigurations().put("option:remove-room", this);
}
for (int id = 13675; id <= 13680; id++) {
if (id < 13678) {
ObjectDefinition.forId(id).getConfigurations().put("option:open", this);
} else {
ObjectDefinition.forId(id).getConfigurations().put("option:go-down", this);
ObjectDefinition.forId(id).getConfigurations().put("option:close", this);
}
ObjectDefinition.forId(id).getConfigurations().put("option:remove-room", this);
}
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
HouseManager house = player.getAttribute("poh_entry", null);
if (house == null) {
player.getPacketDispatch().sendMessage("You're not in your house right now (REPORT).");
return true;
}
GameObject object = (GameObject) node;
switch (option) {
case "open":
ObjectBuilder.replace(object, object.transform(object.getId() + 3), 200);
return true;
case "close":
ObjectBuilder.replace(object, object.transform(object.getId() - 3));
return true;
case "remove-room":
if (player.getLocation().getZ() != 0) {
player.getPacketDispatch().sendMessage("The room below is supporting this room!");
return true;
}
return false;
case "climb":
if (house.getDungeonRegion() == player.getViewport().getRegion()) {
climb(player, 1, house, object);
return true;
}
if (object.getLocation().getZ() > 0) {
climb(player, -1, house, object);
return true;
}
player.getDialogueInterpreter().open("con:climbdial", house, object);
return true;
case "climb-up":
climb(player, 1, house, object);
return true;
case "enter":
case "climb-down":
case "go-down":
climb(player, -1, house, object);
return true;
}
return false;
}
/**
* Climbs the staircase.
* @param player The player.
* @param z The plane difference.
* @param house The house the player is currently in.
* @param object The object.
*/
private static void climb(Player player, int z, HouseManager house, GameObject object) {
Location l = player.getLocation();
int plane = l.getZ() + z;
int roomX = l.getChunkX();
int roomY = l.getChunkY();
Room current = house.getRooms()[l.getZ()][roomX][roomY];
if (plane < 0) { //Dungeon
plane = 3;
}
else if (player.getViewport().getRegion() == house.getDungeonRegion() && plane == 1) {//going up
plane = 0;
}
Room room = house.getRooms()[plane][roomX][roomY];
// boolean stairs = room != null && room.getStairs() != null || room.get;
if (room == null || room.getProperties().isRoof()) {
if (player.getHouseManager().isInHouse(player) && player.getHouseManager().isBuildingMode()) {
player.getDialogueInterpreter().open("con:nfroom", plane, roomX, roomY, current, object);
}
else {
player.getPacketDispatch().sendMessage("This doesn't seem to lead anywhere.");
}
} else {
Location destination = l.transform(0, 0, z);
if (player.getViewport().getRegion() == house.getDungeonRegion()) {
destination = house.getRegion().getBaseLocation().transform(l.getLocalX(), l.getLocalY(), 0);
}
else if (plane == 3) {
destination = house.getDungeonRegion().getBaseLocation().transform(l.getLocalX(), l.getLocalY(), 0);
}
Room r = house.getRoom(destination);
Hotspot h = r.getStairs();
if (h != null && h.getDecorationIndex() > -1) {
player.getProperties().setTeleportLocation(destination);
} else {
player.getPacketDispatch().sendMessage("This doesn't seem to lead anywhere.");
}
}
}
/**
* Handles the climbing dialogue.
* @author Emperor
*/
static final class ClimbPohLadder extends DialoguePlugin {
/**
* Represents the object to use.
*/
private HouseManager house;
/**
* The ladder.
*/
private GameObject ladder;
/**
* Constructs a new {@code ClimbPohLadder} {@code Object}.
*/
public ClimbPohLadder() {
super();
}
/**
* Constructs a new {@code ClimbPohLadder} {@code Object}.
* @param player the player.
*/
public ClimbPohLadder(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new ClimbPohLadder(player);
}
@Override
public boolean open(Object... args) {
house = (HouseManager) args[0];
ladder = (GameObject) args[1];
interpreter.sendOptions("What would you like to do?", "Climb Up.", "Climb Down.");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
switch (buttonId) {
case 1:
player.lock(1);
GameWorld.submit(new Pulse(1) {
@Override
public boolean pulse() {
climb(player, 1, house, ladder);
return true;
}
});
end();
break;
case 2:
player.lock(1);
GameWorld.submit(new Pulse(1) {
@Override
public boolean pulse() {
climb(player, -1, house, ladder);
return true;
}
});
end();
break;
}
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("con:climbdial") };
}
}
/**
* Handles the creating a room on different floor dialogue.
* @author Emperor
*/
static final class BuildDialogue extends DialoguePlugin {
/**
* The plane of the room to build.
*/
private int plane;
/**
* The room x-coordinate.
*/
private int roomX;
/**
* The room y-coordinate.
*/
private int roomY;
/**
* The room we're building on.
*/
private Room room;
/**
* The stairs object.
*/
private GameObject stairs;
/**
* Constructs a new {@code BuildDialogue} {@code Object}.
*/
public BuildDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code BuildDialogue} {@code Object}.
* @param player the player.
*/
public BuildDialogue(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new BuildDialogue(player);
}
@Override
public boolean open(Object... args) {
plane = (Integer) args[0];
roomX = (Integer) args[1];
roomY = (Integer) args[2];
room = (Room) args[3];
stairs = (GameObject) args[4];
stage = 0;
if (stairs.getId() >= 13328 && stairs.getId() <= 13330) {
interpreter.sendPlainMessage(false, "These stairs don't seem to lead anywhere. Do you", "want to build a throne room upstairs?");
stage = 5;
return true;
}
if (plane == 3) {
if (room.getProperties() == RoomProperties.THRONE_ROOM) {
interpreter.sendPlainMessage(false, "These stairs don't seem to lead anywhere. Do you", "want to build an Oubilette?");
} else {
interpreter.sendPlainMessage(false, "These stairs don't seem to lead anywhere. Do you", "want to build a dungeon room?");
}
return true;
}
interpreter.sendPlainMessage(false, "These stairs don't seem to lead anywhere. Do you", "want to build a room at the top?");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
boolean dungeon = plane == 3;
switch (stage) {
case 0:
interpreter.sendOptions("Select an option", "Yes", "No");
stage = 1;
break;
case 1:
switch (buttonId) {
case 1: //yes
if (room.getProperties() == RoomProperties.THRONE_ROOM) {
Room r = Room.create(player, RoomProperties.OUBILETTE);
Direction[] dirs = BuildingUtils.getAvailableRotations(player, r.getExits(), plane, roomX, roomY);
for (Direction d : dirs) {
if (d == room.getRotation()) {
r.setRotation(d);
Hotspot stairs = room.getStairs();
int index = stairs != null ? stairs.getDecorationIndex() : -1;
BuildingUtils.buildRoom(player, r, plane, roomX, roomY, r.getExits(), true);
r.getStairs().setDecorationIndex(index);
end();
return true;
}
}
interpreter.sendPlainMessage(false, "The room you're trying to build doesn't fit.");
stage = 4;
return true;
}
if (dungeon) {
interpreter.sendOptions("Select an option", "Skill Hall", "Quest Hall", "Dungeon Stairs");
} else {
interpreter.sendOptions("Select an option", "Skill Hall", "Quest Hall");
}
stage = 2;
return true;
}
end();
return true;
case 2:
if (dungeon && buttonId == 3) {
stage = 3;
return handle(interfaceId, 1);
}
RoomProperties props = buttonId == 2 ? RoomProperties.QUEST_HALL_2 : RoomProperties.SKILL_HALL_2;
if (plane == 3) {
props = buttonId == 2 ? RoomProperties.QUEST_HALL : RoomProperties.SKILL_HALL;
}
Room r = Room.create(player, props);
Direction[] dirs = BuildingUtils.getAvailableRotations(player, r.getExits(), plane, roomX, roomY);
for (Direction d : dirs) {
if (d == room.getRotation()) {
r.setRotation(d);
Hotspot stairs = room.getStairs();
int index = stairs != null ? stairs.getDecorationIndex() : -1;
r.getStairs().setDecorationIndex(index);
BuildingUtils.buildRoom(player, r, plane, roomX, roomY, r.getExits(), true);
end();
return true;
}
}
interpreter.sendPlainMessage(false, "The room you're trying to build doesn't seem to fit.");
stage = 4;
return true;
case 3:
switch (buttonId) {
case 1: //yes
r = Room.create(player, RoomProperties.DUNGEON_STAIRS);
dirs = BuildingUtils.getAvailableRotations(player, r.getExits(), plane, roomX, roomY);
for (Direction d : dirs) {
if (d == room.getRotation()) {
r.setRotation(d);
Hotspot stairs = room.getStairs();
int index = stairs != null ? stairs.getDecorationIndex() : -1;
BuildingUtils.buildRoom(player, r, plane, roomX, roomY, r.getExits(), true);
r.getStairs().setDecorationIndex(index);
end();
return true;
}
}
interpreter.sendPlainMessage(false, "The room you're trying to build doesn't fit.");
stage = 4;
return true;
case 2:
end();
return true;
}
return true;
case 4:
end();
return true;
case 5:
interpreter.sendOptions("Select an option", "Yes", "No");
stage = 6;
return true;
case 6:
switch (buttonId) {
case 1: //yes
r = Room.create(player, RoomProperties.THRONE_ROOM);
dirs = BuildingUtils.getAvailableRotations(player, r.getExits(), plane, roomX, roomY);
for (Direction d : dirs) {
if (d == room.getRotation()) {
r.setRotation(d);
Hotspot stairs = room.getStairs();
int index = stairs != null ? stairs.getDecorationIndex() : -1;
BuildingUtils.buildRoom(player, r, plane, roomX, roomY, r.getExits(), true);
r.getStairs().setDecorationIndex(index);
end();
return true;
}
}
interpreter.sendPlainMessage(false, "The room you're trying to build doesn't fit.");
stage = 4;
return true;
case 2:
end();
return true;
}
return true;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("con:nfroom") };
}
}
}

View file

@ -0,0 +1,51 @@
package plugin.skill.construction.decoration.bedroom;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import java.util.Calendar;
/**
* ClockPlugin.java
* @author Clayton Williams (hope)
* @date Oct 26, 2015
*/
@InitializablePlugin
public class ClockPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(13169).getConfigurations().put("option:read", this);
ObjectDefinition.forId(13170).getConfigurations().put("option:read", this);
ObjectDefinition.forId(13171).getConfigurations().put("option:read", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
GameObject object = node.asObject();
Calendar now = Calendar.getInstance();
int minuteDisplay = ((int) (now.get(Calendar.MINUTE) / 5)) * 5;
StringBuilder sb = new StringBuilder("It's ");
if (minuteDisplay == 0) {
sb.append("Rune o'clock.");
} else if (minuteDisplay == 15) {
sb.append("a quarter past Rune.");
} else if (minuteDisplay > 0 && minuteDisplay < 30) {
sb.append(minuteDisplay + " past Rune.");
} else if (minuteDisplay == 45) {
sb.append("a quarter till Rune.");
} else {
sb.append((60 - minuteDisplay) + " till Rune.");
}
player.getDialogueInterpreter().sendItemMessage(object.getId() - 5117, sb.toString());
return true;
}
}

View file

@ -0,0 +1,180 @@
package plugin.skill.construction.decoration.chapel;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.Bones;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.audio.Audio;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.game.world.update.flag.context.Graphics;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the offering of bones on an altar.
* @author Splinter
*/
@InitializablePlugin
public class BoneOfferPlugin extends UseWithHandler {
/**
* The offer GFX.
*/
private final Graphics GFX = new Graphics(624);
/**
* The offer Animation.
*/
private final Animation ANIM = new Animation(896);
/**
* Constructor.
*/
public BoneOfferPlugin() {
super(526, 2859, 528, 3183, 3179, 530, 532, 3125, 4812, 3123, 534, 6812, 536, 4830, 4832, 6729, 4834, 14693);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(15270, OBJECT_TYPE, this);
addHandler(8063, OBJECT_TYPE, this);
addHandler(13185, OBJECT_TYPE, this);
addHandler(13188, OBJECT_TYPE, this);
addHandler(13191, OBJECT_TYPE, this);
addHandler(13194, OBJECT_TYPE, this);
addHandler(13197, OBJECT_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
Player player = event.getPlayer();
GameObject left = null;
GameObject right = null;
if (event.getUsedWith().asObject().getRotation() % 2 == 0) {
left = RegionManager.getObject(event.getUsedWith().getLocation().getZ(), event.getUsedWith().getLocation().getX() + 3, event.getUsedWith().getLocation().getY());
right = RegionManager.getObject(event.getUsedWith().getLocation().getZ(), event.getUsedWith().getLocation().getX() - 2, event.getUsedWith().getLocation().getY());
} else {
left = RegionManager.getObject(event.getUsedWith().getLocation().getZ(), event.getUsedWith().getLocation().getX(), event.getUsedWith().getLocation().getY() + 3);
right = RegionManager.getObject(event.getUsedWith().getLocation().getZ(), event.getUsedWith().getLocation().getX(), event.getUsedWith().getLocation().getY() - 2);
}
Bones b = Bones.forId(event.getUsedItem().getId());
if (b != null) {
worship(player, event.getUsedWith().asObject(), left, right, b);
}
return true;
}
/**
* Worships the altar.
* @param player the player
* @param altar the altar object
* @param left the left brazier
* @param right the right brazier
* @param b the bone used
*/
private void worship(final Player player, final GameObject altar, final GameObject left, final GameObject right, final Bones b) {
if (player.getIronmanManager().isIronman() && !player.getHouseManager().isInHouse(player)) {
player.sendMessage("You cannot do this on someone else's altar.");
return;
}
final Location start = player.getLocation();
GameWorld.submit(new Pulse(1) {
int counter = 0;
@Override
public boolean pulse() {
counter++;
if (counter == 1 || counter % 5 == 0) {
if (player.getInventory().remove(new Item(b.getItemId()))) {
player.animate(ANIM);
player.getAudioManager().send(new Audio(958));
player.getPacketDispatch().sendPositionedGraphics(GFX, altar.getLocation());
player.sendMessage(getMessage(isLit(left), isLit(right)));
player.getSkills().addExperience(Skills.PRAYER, b.getExperience() * getMod(altar, isLit(left), isLit(right)));
}
}
return !player.getLocation().equals(start) || !player.getInventory().containsItem(new Item(b.getItemId()));
}
});
}
/**
* Checks if the burner is lit.
* @param obj the object.
*/
private boolean isLit(GameObject obj) {
return obj != null && obj.getId() != 15271 && ObjectDefinition.forId(obj.getId()).getOptions() != null && !ObjectDefinition.forId(obj.getId()).hasAction("Light");
}
/**
* Gets the base modifier of the altar.
* @param altar the altar object
* @return the base bonus.
*/
private double getBase(GameObject altar) {
double base = 150.0;
if (altar == null) {
return base;
}
switch (altar.getId()) {
case 13182:
base = 110.0;
break;
case 13185:
base = 125.0;
break;
case 13188:
base = 150.0;
break;
case 13191:
base = 175.0;
break;
case 13194:
base = 200.0;
break;
case 13197:
base = 250.0;
break;
}
return base;
}
/**
* Gets the total experience modifier.
* @param isLeft if the left is lit.
* @param isRight if the right is lit.
* @return the mod.
*/
private double getMod(GameObject altar, boolean isLeft, boolean isRight) {
double total = getBase(altar);
if (isLeft) {
total += 50.0;
}
if (isRight) {
total += 50.0;
}
return (total / 100);
}
/**
* Gets the proper message.
* @return the message.
*/
private String getMessage(boolean isLeft, boolean isRight) {
return isLeft && isRight ? "The gods are very pleased with your offering." : isLeft || isRight ? "The gods are pleased with your offering." : "The gods accept your offering.";
}
}

View file

@ -0,0 +1,49 @@
package plugin.skill.construction.decoration.chapel;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.node.object.ObjectBuilder;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.tools.RandomFunction;
/**
* Handles the lighting of the torches of the Chapel.
* @author Splinter
*/
@InitializablePlugin
public class TorchLightPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i = 13202; i < 13214; i++) {
ObjectDefinition.forId(i).getConfigurations().put("option:light", this);
}
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
if (player.getIronmanManager().checkRestriction() && !player.getHouseManager().isInHouse(player)) {
return true;
}
if (!player.getInventory().containsItem(new Item(590)) || !player.getInventory().containsItem(new Item(251))) {
player.getDialogueInterpreter().sendDialogue("You'll need a tinderbox and a clean marrentill herb in order to", "light the burner.");
return true;
}
if (player.getInventory().remove(new Item(251))) {
player.lock(1);
player.animate(Animation.create(3687));
player.sendMessage("You burn some marrentill in the incense burner.");
ObjectBuilder.replace(node.asObject(), new GameObject(node.asObject().getId() + 1, node.getLocation()), RandomFunction.random(100, 175));
}
return true;
}
}

View file

@ -0,0 +1,32 @@
package plugin.skill.construction.decoration.combatroom;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the combat ring.
* @author Emperor
*
*/
@InitializablePlugin
public final class CombatRing extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(13129).getConfigurations().put("option:climb-over", this); //Boxing ring
ObjectDefinition.forId(13133).getConfigurations().put("option:climb-over", this); //Fencing ring
ObjectDefinition.forId(13137).getConfigurations().put("option:climb-over", this); //Combat ring
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
return false;
}
}

View file

@ -0,0 +1,33 @@
package plugin.skill.construction.decoration.costume;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the Toy Box POH
* ToyBoxPlugin.java
* @author Lee
* @date 10/2/2017
*/
@InitializablePlugin
public class ToyBoxPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(18802).getConfigurations().put("option:open", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
// TODO Auto-generated method stub
return true;
}
}

View file

@ -0,0 +1,5 @@
/**
* @author Leewo
*
*/
package plugin.skill.construction.decoration.costume;

View file

@ -0,0 +1,76 @@
package plugin.skill.construction.decoration.kitchen;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the Construction beer barrels.
* @author Splinter
*/
@InitializablePlugin
public class BeerBarrelPlugin extends UseWithHandler {
/**
* The object ids
*/
private static final int[] OBJECTS = new int[] {
13568, 13569, 13570, 13571, 13572, 13573
};
/**
* Constructs a new {@Code BeerBarrelPlugin} {@Code Object}
*/
public BeerBarrelPlugin() {
super(1919);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int id : OBJECTS) {
addHandler(id, OBJECT_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
Player player = event.getPlayer();
final GameObject object = (GameObject) event.getUsedWith();
if (player.getInventory().remove(new Item(1919))) {
player.animate(Animation.create(3661 + (object.getId() - 13569)));
player.sendMessage("You fill up your glass with " + object.getName().toLowerCase().replace("barrel", "").trim() + ".");
player.getInventory().add(new Item(getReward(object.getId()), 1));
}
return true;
}
/**
* Get the beer reward based on the interacted barrel.
* @return the item to give.
*/
public int getReward(int barrelId) {
switch (barrelId) {
case 13568:
return 1917;
case 13569:
return 5763;
case 13570:
return 1905;
case 13571:
return 1909;
case 13572:
return 1911;
case 13573:
return 5755;
}
return 1917;
}
}

View file

@ -0,0 +1,148 @@
package plugin.skill.construction.decoration.kitchen;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
/**
* Handles the interactions for the three Larders.
* @author Splinter
*/
@InitializablePlugin
public final class LarderPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
PluginManager.definePlugin(new LarderDialogue());
ObjectDefinition.forId(13565).getConfigurations().put("option:search", this);
ObjectDefinition.forId(13566).getConfigurations().put("option:search", this);
ObjectDefinition.forId(13567).getConfigurations().put("option:search", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.getDialogueInterpreter().open(42048, node.getId());
return true;
}
/**
* Dialogue options for the Larders.
* @author Splinter
* @version 1.0
*/
public final class LarderDialogue extends DialoguePlugin {
/**
* Constructs a new {@code LarderDialogue} {@code Object}.
*/
public LarderDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code LarderDialogue} {@code Object}.
*
* @param player
* the player.
*/
public LarderDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new LarderDialogue(player);
}
@Override
public boolean open(Object... args) {
int id = (int) args[0];
switch (id) {
case 13565:
interpreter.sendOptions("Select an Option", "Tea Leaves", "Bucket of Milk");
stage = 1;
break;
case 13566:
interpreter.sendOptions("Select an Option", "Tea Leaves", "Bucket of Milk", "Eggs", "Pot of Flour");
stage = 1;
break;
case 13567:
interpreter.sendOptions("Select an Option", "Tea Leaves", "Bucket of Milk", "Eggs", "Pot of Flour", "More Options");
stage = 1;
break;
}
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
if (player.getInventory().freeSlots() < 1) {
player.sendMessage("You need at least one free inventory space to take from the larder.");
end();
return true;
}
switch (stage) {
case 1:
switch (buttonId) {
case 1:
player.getInventory().add(new Item(7738, 1));
end();
break;
case 2:
player.getInventory().add(new Item(1927, 1));
end();
break;
case 3:
player.getInventory().add(new Item(1944, 1));
end();
break;
case 4:
player.getInventory().add(new Item(1933, 1));
end();
break;
case 5:
player.getDialogueInterpreter().sendOptions(
"Select an Option", "Potatoes", "Garlic", "Onions", "Cheese");
stage = 2;
break;
}
break;
case 2:
switch (buttonId) {
case 1:
player.getInventory().add(new Item(1942, 1));
end();
break;
case 2:
player.getInventory().add(new Item(1550, 1));
end();
break;
case 3:
player.getInventory().add(new Item(1957, 1));
end();
break;
case 4:
player.getInventory().add(new Item(1985, 1));
end();
break;
}
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 42048 };
}
}
}

View file

@ -0,0 +1,238 @@
package plugin.skill.construction.decoration.kitchen;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
/**
* Handles the shelves in the kitchen room.
* @author Splinter
*/
@InitializablePlugin
public final class ShelfPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
PluginManager.definePlugin(new ShelfDialogue());
for (int i = 13545; i < 13552; i++) {
ObjectDefinition.forId(i).getConfigurations().put("option:search", this);
}
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.getDialogueInterpreter().open(778341, node.getId());
return true;
}
/**
* Dialogue options for the shelves, what a mess!
* @author Splinter
* @version 1.0
*/
public final class ShelfDialogue extends DialoguePlugin {
/**
* Constructs a new {@code ShelfDialogue} {@code Object}.
*/
public ShelfDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code ShelfDialogue} {@code Object}.
* @param player the player.
*/
public ShelfDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new ShelfDialogue(player);
}
@Override
public boolean open(Object... args) {
int id = (int) args[0];
switch (id) {
case 13545:// wood 1
interpreter.sendOptions("Select an Option", "Kettle", "Teapot", "Clay cup");
stage = 1;
break;
case 13546:// wood 2
interpreter.sendOptions("Select an Option", "Kettle", "Teapot", "Clay cup", "Empty beer glass");
stage = 1;
break;
case 13547:// wood 3
interpreter.sendOptions("Select an Option", "Kettle", "Teapot", "Clay cup", "Empty beer glass", "Cake tin");
stage = 1;
break;
case 13548:// oak 1
interpreter.sendOptions("Select an Option", "Kettle", "Teapot", "Clay cup", "Empty beer glass", "Bowl");
stage = 2;
break;
case 13549:// oak 2
interpreter.sendOptions("Select an Option", "Kettle", "Teapot", "Porcelain cup", "Empty beer glass", "More Options");
stage = 3;
break;
case 13550:// teak 1
case 13551:
interpreter.sendOptions("Select an Option", "Kettle", "Teapot", "Porcelain cup", "Empty beer glass", "More Options");
stage = 5;
break;
}
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
if (player.getInventory().freeSlots() < 1) {
player.sendMessage("You need at least one free inventory space to take from the shelves.");
end();
return true;
}
switch (stage) {
case 1:// all wood shelves
switch (buttonId) {
case 1:
end();
player.getInventory().add(new Item(7688, 1));
break;
case 2:
end();
player.getInventory().add(new Item(7702, 1));
break;
case 3:
end();
player.getInventory().add(new Item(7728, 1));
break;
case 4:
end();
player.getInventory().add(new Item(1919, 1));
break;
case 5:
end();
player.getInventory().add(new Item(1887, 1));
break;
}
break;
case 2:// Oak shelf #1
switch (buttonId) {
case 1:
end();
player.getInventory().add(new Item(7688, 1));
break;
case 2:
end();
player.getInventory().add(new Item(7702, 1));
break;
case 3:
end();
player.getInventory().add(new Item(7728, 1));
break;
case 4:
end();
player.getInventory().add(new Item(1919, 1));
break;
case 5:
end();
player.getInventory().add(new Item(1923, 1));
break;
}
break;
case 3:// Oak shelves #2 only
switch (buttonId) {
case 1:
end();
player.getInventory().add(new Item(7688, 1));
break;
case 2:
end();
player.getInventory().add(new Item(7702, 1));
break;
case 3:
end();
player.getInventory().add(new Item(4244, 1));
break;
case 4:
end();
player.getInventory().add(new Item(1919, 1));
break;
case 5:
interpreter.sendOptions("Select an Option", "Bowl", "Cake tin");
stage = 4;
break;
}
break;
case 4:// Oak shelves #2 only
switch (buttonId) {
case 1:
end();
player.getInventory().add(new Item(1923, 1));
break;
case 2:
end();
player.getInventory().add(new Item(1887, 1));
break;
}
case 5:// teak shelves
switch (buttonId) {
case 1:
end();
player.getInventory().add(new Item(7688, 1));
break;
case 2:
end();
player.getInventory().add(new Item(7702, 1));
break;
case 3:
end();
player.getInventory().add(new Item(7735, 1));
break;
case 4:
end();
player.getInventory().add(new Item(1919, 1));
break;
case 5:
interpreter.sendOptions("Select an Option", "Bowl", "Pie dish", "Empty pot");
stage = 6;
break;
}
break;
case 6:// teak shelves
switch (buttonId) {
case 1:
end();
player.getInventory().add(new Item(1923, 1));
break;
case 2:
end();
player.getInventory().add(new Item(2313, 1));
break;
case 3:
end();
player.getInventory().add(new Item(1931, 1));
break;
}
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 778341 };
}
}
}

View file

@ -0,0 +1,258 @@
package plugin.skill.construction.decoration.portalchamber;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.skill.free.runecrafting.Rune;
import org.crandor.game.content.skill.member.construction.Decoration;
import org.crandor.game.content.skill.member.construction.Hotspot;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
/**
* PortalChamberPlugin
* @author Clayton Williams
* @date Jan 2, 2016
*/
@InitializablePlugin
public class PortalChamberPlugin extends OptionHandler {
/**
* Locations
* @author Clayton Williams
* @date Jan 3, 2016
*/
private static enum Locations {
VARROCK(Location.create(3213, 3428, 0), new Item(Rune.FIRE.getRune().getId(), 100), new Item(Rune.AIR.getRune().getId(), 300), new Item(Rune.LAW.getRune().getId(), 100)),
LUMBRIDGE(Location.create(3222, 3217, 0), new Item(Rune.EARTH.getRune().getId(), 100), new Item(Rune.AIR.getRune().getId(), 300), new Item(Rune.LAW.getRune().getId(), 100)),
FALADOR(Location.create(2965, 3380, 0), new Item(Rune.WATER.getRune().getId(), 100), new Item(Rune.AIR.getRune().getId(), 300), new Item(Rune.LAW.getRune().getId(), 100)),
CAMELOT(Location.create(2730, 3485, 0), new Item(Rune.AIR.getRune().getId(), 500), new Item(Rune.LAW.getRune().getId(), 100)),
ARDOUGNE(Location.create(2663, 3305, 0), new Item(Rune.WATER.getRune().getId(), 200), new Item(Rune.LAW.getRune().getId(), 200)),
YANILLE(Location.create(2554, 3114, 0), new Item(Rune.EARTH.getRune().getId(), 200), new Item(Rune.LAW.getRune().getId(), 200)),
KHARYRLL(Location.create(3493, 3474, 0), new Item(Rune.BLOOD.getRune().getId(), 100), new Item(Rune.LAW.getRune().getId(), 200));
/**
* The location to teleport to
*/
private Location location;
/**
* The rune requirements
*/
private Item[] runes;
/**
* Locations
* @param location
* @param runes
*/
Locations(Location location, Item... runes) {
this.location = location;
this.runes = runes;
}
}
/**
* Directs a portal
* @param player
* @param identifier
*/
public static void direct(Player player, String identifier) {
player.getInterfaceManager().closeSingleTab();
int dpId = player.getAttribute("con:dp-id", 1);
Hotspot[] hotspots = player.getHouseManager().getRoom(player.getLocation()).getHotspots();
for (int i = 0; i < hotspots.length; i++) {
Hotspot h = hotspots[i];
if (h.getHotspot().name().equalsIgnoreCase("PORTAL" + dpId)) {
if (h.getDecorationIndex() == -1) {
player.sendMessage("You must build a portal frame first!");
return;
}
Decoration previous = h.getHotspot().getDecorations()[h.getDecorationIndex()];
String name = previous.name();
String prefix = "TEAK";
if (name.toLowerCase().contains("mahogany")) {
prefix = "MAHOGANY";
} else if (name.toLowerCase().contains("marble")) {
prefix = "MARBLE";
}
for (Locations l : Locations.values()) {
if (l.name().contains(identifier)) {
Item[] runes = l.runes;
if (!player.getInventory().containsItems(runes)) {
player.sendMessage("You do not have the required runes to build this portal");
return;
}
player.getInventory().remove(runes);
break;
}
}
h.setDecorationIndex(h.getHotspot().getDecorationIndex(Decoration.forName(prefix + "_" + identifier + "_" + "PORTAL")));
player.getHouseManager().reload(player, player.getHouseManager().isBuildingMode()); //TODO replace object live instead?
}
}
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(13639).getConfigurations().put("option:direct-portal", this);
ObjectDefinition.forId(13639).getConfigurations().put("option:scry", this);
ObjectDefinition.forId(13640).getConfigurations().put("option:direct-portal", this);
ObjectDefinition.forId(13641).getConfigurations().put("option:direct-portal", this);
for (int i = 13615; i <= 13635; i++) {
ObjectDefinition.forId(i).getConfigurations().put("option:enter", this);
}
PluginManager.definePlugin(new DirectPortalDialogue());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
GameObject object = node.asObject();
switch (option) {
case "direct-portal":
if (!player.getHouseManager().isBuildingMode()) {
player.sendMessage("You can currently only do this in building mode.");
return true;
}
player.getDialogueInterpreter().open(DialogueInterpreter.getDialogueKey("con:directportal"));
return true;
case "enter":
String objectName = object.getName();
for (Locations l : Locations.values()) {
if (objectName.toLowerCase().contains(l.name().toLowerCase())) {
player.teleport(l.location);
if (player.getHouseManager().isInHouse(player) && node.getId() == 13635) {
//player.getAchievementDiaryManager().getDiary(DiaryType.MORYTANIA).updateTask(player, 2, 0, true);
}
break;
}
}
return true;
case "scry":
//wtf
return true;
}
return false;
}
/**
* DirectPortalDialogue.java
* @author Clayton Williams
* @date Jan 2, 2016
*/
private static final class DirectPortalDialogue extends DialoguePlugin {
/**
* DirectPortalDialogue
*/
public DirectPortalDialogue() {
/**
* Empty
*/
}
/**
* DirectPortalDialogue
* @param player
*/
public DirectPortalDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new DirectPortalDialogue(player);
}
@Override
public boolean open(Object... args) {
interpreter.sendOptions("Select a portal", "Portal 1", "Portal 2", "Portal 3");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
player.setAttribute("con:dp-id", buttonId);
//DIRECT_OPTIONS.open(player);
end();
return true;
}
@Override
public int[] getIds() {
return new int[]{DialogueInterpreter.getDialogueKey("con:directportal")};
}
}
/**
* The direct options build
*/
/*private final static TabbedOption DIRECT_OPTIONS = new TabbedOption("Direct Portal", "Select an option",
new Page(
new PageAction("Varrock Portal") {
@Override
public boolean run(Player player) {
PortalChamberPlugin.direct(player, "VARROCK");
return true;
}
},
new PageAction("Lumbridge Portal") {
@Override
public boolean run(Player player) {
PortalChamberPlugin.direct(player, "LUMBRIDGE");
return true;
}
},
new PageAction("Falador Portal") {
@Override
public boolean run(Player player) {
PortalChamberPlugin.direct(player, "FALADOR");
return true;
}
},
new PageAction("Camelot Portal") {
@Override
public boolean run(Player player) {
PortalChamberPlugin.direct(player, "CAMELOT");
return true;
}
},
new PageAction("Ardougne Portal") {
@Override
public boolean run(Player player) {
PortalChamberPlugin.direct(player, "ARDOUGNE");
return true;
}
}
), new Page(
new PageAction("Yanille Portal") {
@Override
public boolean run(Player player) {
PortalChamberPlugin.direct(player, "YANILLE");
return true;
}
},
new PageAction("Kharyrll Portal") {
@Override
public boolean run(Player player) {
PortalChamberPlugin.direct(player, "KHARYRLL");
return true;
}
}
)
);*/
}

View file

@ -0,0 +1,94 @@
package plugin.skill.construction.decoration.questhall;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.DialogueAction;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.game.world.update.flag.context.Graphics;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the POH Mounted Glory.
* @author Splinter
*/
@InitializablePlugin
public class MountedGloryPlugin extends OptionHandler {
/**
* Represents the teleport animation.
*/
private static final Animation ANIMATION = new Animation(714);
/**
* Represents the graphics to use.
*/
private static final Graphics GRAPHICS = new Graphics(308, 100, 50);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(13523).getConfigurations().put("option:rub", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
DialogueInterpreter interpreter = player.getDialogueInterpreter();
interpreter.sendOptions("Select a location.", "Edgeville", "Karamja", "Draynor Village", "Al-Kharid", "Nowhere.");
interpreter.addAction(new DialogueAction() {
@Override
public void handle(Player player, int buttonId) {
switch (buttonId) {
case 2:
teleport(player, Location.create(3087, 3495, 0));
break;
case 3:
teleport(player, Location.create(2919, 3175, 0));
break;
case 4:
teleport(player, Location.create(3081, 3250, 0));
break;
case 5:
teleport(player, Location.create(3304, 3124, 0));
break;
}
}
});
return true;
}
/**
* Method used to teleport to a location.
* @param player the player.
* @param location the location.
*/
private boolean teleport(final Player player, final Location location) {
if (player.isTeleBlocked()) {
player.sendMessage("A magical force has stopped you from teleporting.");
return false;
}
player.lock();
player.visualize(ANIMATION, GRAPHICS);
player.getImpactHandler().setDisabledTicks(4);
GameWorld.submit(new Pulse(4, player) {
@Override
public boolean pulse() {
player.unlock();
player.getProperties().setTeleportLocation(location);
player.getAnimator().reset();
return true;
}
});
return true;
}
}

View file

@ -0,0 +1,210 @@
package plugin.skill.construction.decoration.study;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.construction.Decoration;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.system.task.Pulse;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
import plugin.interaction.item.TeleTabsOptionPlugin;
/**
* Handles the lectern
* LecternPlugin.java
* @author Clayton Williams
* @date Oct 30, 2016
*/
@InitializablePlugin
public class LecternPlugin extends OptionHandler {
/**
* Soft clay
*/
private static final Item SOFT_CLAY = new Item(1761, 1);
/**
* TeleTabButton
*/
private static enum TeleTabButton {
ARDOUGNE(2, 51, 66, new Item(TeleTabsOptionPlugin.TeleTabs.ADDOUGNE_TELEPORT.getItem()), new Decoration[] { Decoration.TEAK_EAGLE_LECTERN, Decoration.MAHOGANY_EAGLE_LECTERN }, SOFT_CLAY, new Item(563, 2), new Item(555, 2)),
BONES_TO_BANANNAS(3, 15, 32, new Item(8014), new Decoration[] { Decoration.DEMON_LECTERN, Decoration.TEAK_DEMON_LECTERN, Decoration.MAHOGANY_DEMON_LECTERN }, SOFT_CLAY, new Item(561, 1), new Item(557, 2), new Item(555, 2)),
BONES_TO_PEACHES(4, 60, 36, new Item(8015), new Decoration[] { Decoration.MAHOGANY_DEMON_LECTERN }, SOFT_CLAY, new Item(561, 2), new Item(557, 4), new Item(555, 4)),
CAMELOT(5, 45, 56, new Item(TeleTabsOptionPlugin.TeleTabs.CAMELOT_TELEPORT.getItem()), new Decoration[] { Decoration.TEAK_EAGLE_LECTERN, Decoration.MAHOGANY_EAGLE_LECTERN }, SOFT_CLAY, new Item(563), new Item(556, 5)),
ENCHANT_DIAMOND(6, 57, 62, new Item(8019), new Decoration[] { Decoration.TEAK_DEMON_LECTERN, Decoration.MAHOGANY_DEMON_LECTERN }, SOFT_CLAY, new Item(564), new Item(557, 10)),
ENCHANT_DRAGONSTONE(7, 68, 60, new Item(8020), new Decoration[] { Decoration.MAHOGANY_DEMON_LECTERN }, SOFT_CLAY, new Item(564), new Item(557, 15), new Item(555, 15)),
ENCHANT_EMERALD(8, 27, 34, new Item(8017), new Decoration[] { Decoration.DEMON_LECTERN, Decoration.TEAK_DEMON_LECTERN, Decoration.MAHOGANY_DEMON_LECTERN }, SOFT_CLAY, new Item(564), new Item(556, 3)),
ENCHANT_ONYX(9, 87, 84, new Item(8021), new Decoration[] { Decoration.MAHOGANY_DEMON_LECTERN }, SOFT_CLAY, new Item(564), new Item(557, 20), new Item(554, 20)),
ENCHANT_RUBY(10, 49, 52, new Item(8018), new Decoration[] { Decoration.TEAK_DEMON_LECTERN, Decoration.MAHOGANY_DEMON_LECTERN }, SOFT_CLAY, new Item(564), new Item(554, 5)),
ENCHANT_SAPPHIRE(11, 7, 12, new Item(8016), new Decoration[] { Decoration.OAK_LECTERN, Decoration.EAGLE_LECTERN, Decoration.TEAK_EAGLE_LECTERN, Decoration.MAHOGANY_EAGLE_LECTERN, Decoration.DEMON_LECTERN, Decoration.TEAK_DEMON_LECTERN, Decoration.MAHOGANY_DEMON_LECTERN}, SOFT_CLAY, new Item(564), new Item(555)),
FALADOR(12, 37, 48, new Item(TeleTabsOptionPlugin.TeleTabs.FALADOR_TELEPORT.getItem()), new Decoration[] { Decoration.EAGLE_LECTERN, Decoration.TEAK_EAGLE_LECTERN, Decoration.MAHOGANY_EAGLE_LECTERN }, SOFT_CLAY, new Item(563), new Item(555), new Item(556, 3)),
LUMBRIDGE(13, 31, 40, new Item(TeleTabsOptionPlugin.TeleTabs.LUMBRIDGE_TELEPORT.getItem()), new Decoration[] { Decoration.EAGLE_LECTERN, Decoration.TEAK_EAGLE_LECTERN, Decoration.MAHOGANY_EAGLE_LECTERN }, SOFT_CLAY, new Item(563), new Item(557), new Item(556, 3)),
HOUSE(14, 40, 30, new Item(8013), new Decoration[] { Decoration.MAHOGANY_EAGLE_LECTERN }, SOFT_CLAY, new Item(563), new Item(557), new Item(556)),
VARROCK(15, 25, 35, new Item(TeleTabsOptionPlugin.TeleTabs.VARROCK_TELEPORT.getItem()), new Decoration[] { Decoration.OAK_LECTERN, Decoration.EAGLE_LECTERN, Decoration.TEAK_EAGLE_LECTERN, Decoration.MAHOGANY_EAGLE_LECTERN, Decoration.DEMON_LECTERN, Decoration.TEAK_DEMON_LECTERN, Decoration.MAHOGANY_DEMON_LECTERN }, SOFT_CLAY, new Item(563), new Item(554), new Item(556, 3)),
WATCHTOWER(16, 58, 74, new Item(TeleTabsOptionPlugin.TeleTabs.WATCH_TOWER_TELEPORT.getItem()), new Decoration[] { Decoration.MAHOGANY_EAGLE_LECTERN }, SOFT_CLAY, new Item(563, 2), new Item(557, 2)),
;
/**
* The button id
*/
private final int buttonId;
/**
* The level and xp
*/
private final int level, xp;
/**
* The item
*/
private final Item tabItem;
/**
* The required decoration (lectern)
*/
private final Decoration[] requiredDecorations;
/**
* The required items
*/
private final Item[] requiredItems;
/**
* TeleTabButton
* @param id
*/
private TeleTabButton(int id, int level, int xp, Item tabItem, Decoration[] requiredDecorations, Item... requiredItems) {
this.buttonId = id;
this.level = level;
this.xp = xp;
this.tabItem = tabItem;
this.requiredDecorations = requiredDecorations;
this.requiredItems = requiredItems;
}
/**
* Checks if the player can make this tab
* @param player
* @return
*/
private boolean canMake(Player player) {
int objectId = player.getAttribute("ttb:objectid");
if (player.getSkills().getLevel(Skills.MAGIC) < level) {
player.sendMessage("You need a magic level of " + level + " to make that!");
return false;
}
if (this.equals(TeleTabButton.BONES_TO_PEACHES) && !player.getSavedData().getActivityData().isBonesToPeaches()) {
player.sendMessages("You need the Bones to Peaches ability purchased from MTA before making these.", "This requirement doesn't apply to actually using the tabs.");
return false;
}
boolean found = false;
for (Decoration d : requiredDecorations)
if (d.getObjectId() == objectId)
found = true;
if (!found) {
player.sendMessage("You're unable to make this tab on this specific lectern.");
return false;
}
for (Item item : requiredItems) {
if (!player.getInventory().containsItem(item)) {
//TODO staffs
player.sendMessage("You don't have enough materials.");
return false;
}
}
return true;
}
/**
* Gets the button for the id
* @param id
* @return
*/
private static TeleTabButton forId(int id) {
for (TeleTabButton ttb : values()) {
if (ttb.buttonId == id)
return ttb;
}
return null;
}
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i = 13642; i <= 13648; i++) {
ObjectDefinition.forId(i).getConfigurations().put("option:study", this);
}
PluginManager.definePlugin(new TeleTabInterface());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
int id = node.asObject().getId();
player.setAttribute("ttb:objectid", id);
player.getInterfaceManager().openComponent(400);
int bits = 0;
for (TeleTabButton t : TeleTabButton.values()) {
if (t.canMake(player))
bits |= (1 << t.buttonId);
}
player.getConfigManager().set(2005, bits);
return true;
}
/**
* TeleTabInterface.java
* @author Clayton Williams
* @date Oct 30, 2016
*/
private static class TeleTabInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(400, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
final TeleTabButton ttb = TeleTabButton.forId(button);
if (ttb != null && ttb.canMake(player)) {
//player.animate(new Animation(733));
player.getInterfaceManager().close();
player.getPulseManager().run(new Pulse(1) {
@Override
public boolean pulse() {
if (!ttb.canMake(player)) {
return true;
}
if (player.getInventory().freeSlots() == 0) {
player.sendMessage("You don't have enough space in your inventory to make this.");
return true;
}
//player.animate(new Animation(733));
if (player.getInventory().remove(ttb.requiredItems)) {
player.getInventory().add(ttb.tabItem);
player.getSkills().addExperience(Skills.MAGIC, ttb.xp / 2, true);
}
//player.animate(new Animation(-1));
return false;
}
});
}
return true;
}
}
}

View file

@ -0,0 +1,235 @@
package plugin.skill.construction.decoration.workshop;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.construction.BuildingUtils;
import org.crandor.game.content.skill.member.construction.Decoration;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
/**
* Handles the clockmakers bench in the workshop
* ClockmakersBenchPlugin.java
* @author Clayton Williams (hope)
* @date Oct 29, 2015
*/
@InitializablePlugin
public class ClockmakersBenchPlugin extends OptionHandler {
/**
* Stores data for things created by the clockmakers bench
* ClockmakersBenchPlugin.java
* @author Clayton Williams
* @date Oct 30, 2015
*/
private enum Craftable {
TOY_HORSEY(2520, 10, BuildingUtils.PLANK),
CLOCKWORK(8792, 8, new Item(2353)),
TOY_SOLDIER(7759, 13, BuildingUtils.PLANK, new Item(8792)),
TOY_DOLL(7763, 18, BuildingUtils.PLANK, new Item(8792)),
TOY_MOUSE(7767, 33, BuildingUtils.PLANK, new Item(8792)),
TOY_CAT(7771, 85, BuildingUtils.PLANK, new Item(8792)),
WATCH(2575, 28, new Item(8792), new Item(2353)),
SEXTANT(2574, 23, new Item(2353));
/**
* The itemId to give after making this
*/
private int itemId;
/**
* The materials needed to make this
*/
private Item[] materials;
/**
* The crafting level required to make this
*/
private int craftingLevel;
/**
* Craftable
* @param itemId
* @param craftingLevel
* @param materials
*/
Craftable(int itemId, int craftingLevel, Item... materials) {
this.itemId = itemId;
this.craftingLevel = craftingLevel;
this.materials = materials;
}
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(13709).getConfigurations().put("option:craft", this);
ObjectDefinition.forId(13710).getConfigurations().put("option:craft", this);
ObjectDefinition.forId(13711).getConfigurations().put("option:craft", this);
ObjectDefinition.forId(13712).getConfigurations().put("option:craft", this);
PluginManager.definePlugin(new ClockmakerBenchDialogue());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.getDialogueInterpreter().open(DialogueInterpreter.getDialogueKey("con:clockbench"), node.asObject());
return true;
}
/**
* Handles the dialogue for clock bench
* @author Clayton Williams
* @date Oct 29, 2015
*/
private final class ClockmakerBenchDialogue extends DialoguePlugin {
/**
* The crafting table decoration
*/
Decoration decoration;
/**
* ClockmakerBenchDialogue
*/
public ClockmakerBenchDialogue() {
/**
* Empty
*/
}
/**
* ClockmakerBenchDialogue
* @param player
*/
public ClockmakerBenchDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new ClockmakerBenchDialogue(player);
}
@Override
public boolean open(Object... args) {
GameObject object = (GameObject) args[0];
decoration = Decoration.forObjectId(object.getId());
if (decoration != null) {
switch (decoration) {
case CRAFTING_TABLE_1:
interpreter.sendOptions("Select an Option", "Toy Horsey", "Nevermind");
break;
case CRAFTING_TABLE_2:
interpreter.sendOptions("Select an Option", "Toy Horsey", "Clockwork Mechanism");
break;
case CRAFTING_TABLE_3:
interpreter.sendOptions("Select an Option", "Toy Horsey", "Clockwork Mechanism", "Clockwork Devices");
break;
case CRAFTING_TABLE_4:
interpreter.sendOptions("Select an Option", "Toy Horsey", "Clockwork Mechanism", "Clockwork Devices", "Watch", "Sextant");
break;
default:
break;
}
}
stage = 1;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 1:
switch (buttonId) {
case 1:
case 2:
if (decoration == Decoration.CRAFTING_TABLE_1 && buttonId == 2) {
end();
return true;
}
craftItem(buttonId == 1 ? Craftable.TOY_HORSEY : Craftable.CLOCKWORK);
stage = 3;
break;
case 3:
if (decoration == Decoration.CRAFTING_TABLE_3) {
interpreter.sendOptions("Select an Option", "Clockwork Soldier", "Clockwork Doll");
} else if (decoration == Decoration.CRAFTING_TABLE_4) {
interpreter.sendOptions("Select an Option", "Clockwork Soldier", "Clockwork Doll", "Clockwork Mouse", "Clockwork Cat");
}
stage = 2;
break;
case 4:
case 5:
craftItem(buttonId == 4 ? Craftable.WATCH : Craftable.SEXTANT);
stage = 3;
break;
}
break;
case 2:
switch (buttonId) {
case 1:
craftItem(Craftable.TOY_SOLDIER);
break;
case 2:
craftItem(Craftable.TOY_DOLL);
break;
case 3:
craftItem(Craftable.TOY_MOUSE);
break;
case 4:
craftItem(Craftable.TOY_CAT);
break;
}
stage = 3;
break;
case 3:
end();
break;
}
return true;
}
/**
* Attempts to craft an item
* @param c - the craftable to make
*/
private void craftItem(Craftable c) {
if (c != null) {
if (player.getSkills().getLevel(Skills.CRAFTING) < c.craftingLevel) {
interpreter.sendDialogue("You need level " + c.craftingLevel + " crafting to make that.");
return;
}
for (Item n : c.materials) {
if (!player.getInventory().containsItem(n)) {
interpreter.sendDialogue("You need a " + ItemDefinition.forId(n.getId()).getName() + " to make that!");
return;
}
}
for (Item n : c.materials) {
n.setAmount(1);
player.getInventory().remove(n);
}
player.getSkills().addExperience(Skills.CRAFTING, 15);
player.getInventory().add(new Item(c.itemId, 1));
player.animate(BuildingUtils.BUILD_MID_ANIM);
interpreter.sendDialogue("You made a " + ItemDefinition.forId(c.itemId).getName() + "!");
}
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("con:clockbench") };
}
}
}

View file

@ -0,0 +1,171 @@
package plugin.skill.construction.decoration.workshop;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
import java.util.ArrayList;
import java.util.List;
/**
* Handles the 5 types of tool stores
* ToolsPlugin.java
* @author Clayton Williams
* @date Oct 29, 2015
*
*/
@InitializablePlugin
public class ToolsPlugin extends OptionHandler {
/**
* The different tool stores
* @author Clayton Williams
* @date Oct 29, 2015
*/
private enum ToolStore {
TOOLSTORE_1(13699, 8794, 1755, 2347, 1735),
TOOLSTORE_2(13700, 1925, 952, 590),
TOOLSTORE_3(13701, 1757, 1785, 1733),
TOOLSTORE_4(13702, 1595, 1597, 1592, 1599, 5523),
TOOLSTORE_5(13703, 5341, 952, 676, 5343, 5331);
/**
* The object id of the tool store
*/
private int objectId;
/**
* The tools included
*/
private int[] tools;
/**
* ToolStore
* @param objectId
* @param tools
*/
ToolStore(int objectId, int... tools) {
this.objectId = objectId;
this.tools = tools;
}
/**
* Gets the toolstore from an object id
* @param objectId - the object id
* @return
*/
private static ToolStore forId(int objectId) {
for (ToolStore t : ToolStore.values()) {
if (t.objectId == objectId) {
return t;
}
}
return null;
}
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (ToolStore t : ToolStore.values()) {
ObjectDefinition.forId(t.objectId).getConfigurations().put("option:search", this);
}
PluginManager.definePlugin(new ToolDialogue());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
GameObject object = node.asObject();
ToolStore ts = ToolStore.forId(object.getId());
if (ts != null) {
player.getDialogueInterpreter().open(DialogueInterpreter.getDialogueKey("con:tools"), ts);
}
return true;
}
/**
* Handles the tool dialogue
* @author Clayton Williams
* @date Oct 29, 2015
*/
private final class ToolDialogue extends DialoguePlugin {
/**
* The tool store being used
*/
private ToolStore toolStore;
/**
* ToolDialogue
*/
private ToolDialogue() {
/**
* Empty
*/
}
/**
* ToolDialogue
* @param player
*/
public ToolDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new ToolDialogue(player);
}
@Override
public boolean open(Object... args) {
toolStore = (ToolStore) args[0];
List<String> itemNames = new ArrayList<String>();
for(int itemId : toolStore.tools) {
ItemDefinition n = ItemDefinition.forId(itemId);
itemNames.add(n.getName());
}
interpreter.sendOptions("Select a Tool", itemNames.toArray(new String[itemNames.size()]));
stage = 1;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 1:
Item item = new Item(toolStore.tools[buttonId - 1], 1);
if (player.getInventory().freeSlots() <= 0) {
interpreter.sendDialogue("You have no space in your inventory.");
stage = 2;
return true;
}
player.getInventory().add(item);
end();
return true;
case 2:
end();
return true;
}
return false;
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("con:tools") };
}
}
}

View file

@ -0,0 +1,567 @@
package plugin.skill.construction.npc;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.dialogue.FacialExpression;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.construction.HouseManager;
import org.crandor.game.content.skill.member.construction.Servant;
import org.crandor.game.content.skill.member.construction.ServantType;
import org.crandor.game.interaction.MovementPulse;
import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.IronmanMode;
import org.crandor.game.node.item.Item;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.path.Pathfinder;
import plugin.interaction.inter.SawmillPlankInterface.Plank;
/**
* Handles the Servant's dialogues.
* @author Splinter
* @date 9/23/2015
* @version 0.98 (TODO: Missing a few dialogues)
*/
public class HouseServantDialogue extends DialoguePlugin {
/**
* If using the sawmill.
*/
private boolean sawmill;
/**
* The logs
*/
private Item logs;
/**
* Constructs a new {@code ServantDialogue} {@code Object}.
*/
public HouseServantDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code ServantDialogue} {@code Object}.
* @param player the player.
*/
public HouseServantDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new HouseServantDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
HouseManager manager = player.getHouseManager();
boolean inHouse = manager.isInHouse(player);
if (args.length > 1) { //Parse options from our "use-with" handler
sawmill = (boolean) args[1];
logs = (Item) args[2];
}
if (player.getIronmanManager().checkRestriction(IronmanMode.ULTIMATE)) {
player.sendMessage("Ultimate Ironmen cannot hire butlers.");
return true;
}
if (!manager.hasHouse() && inHouse) {
interpreter.sendDialogues(npc, npc.getId() == 4243 ? FacialExpression.NORMAL : null, "You don't have a house that I can work in.", "I'll be waiting here if you decide to buy a house.");
stage = 100;
return true;
}
if (!manager.hasServant()) {
ServantType type = ServantType.forId(npc.getId());
if(player.getSkills().getLevel(Skills.CONSTRUCTION) >= type.getLevel()){
interpreter.sendDialogues(npc, npc.getId() == 4243 ? FacialExpression.NORMAL : null, "You're not aristocracy, but I suppose you'd do. Do you", "want a good cook for " + type.getCost() + " coins?");
stage = 0;
return true;
}
interpreter.sendDialogues(npc, npc.getId() == 4243 ? FacialExpression.NORMAL : null, "You need a Construction level of " + type.getLevel() + " and you must not", "currently have another person working for you", "in order to hire me.");
stage = 100;
return true;
} else {
Servant servant = manager.getServant();
if(servant.getItem() == null){
servant.setItem(new Item(0, 0));
}
if (inHouse) {
follow(player, servant);
if (sawmill) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "Very well, I will take these logs to the mill and", "have them converted into planks.");
stage = 110;
return true;
}
if (servant.getItem().getAmount() > 0) {
if(player.getInventory().freeSlots() < 1){
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I have returned with what you asked me to", "retrieve. As I see your inventory is full, I shall wait", "with these " + servant.getItem().getAmount()+" items until you are ready.");
stage = 100;
return true;
}
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I have returned with what you asked me to", "retrieve.");
stage = 150;
return true;
}
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "Yes, " + (player.getAppearance().isMale() ? "sir" : "ma'am") + "?", "You have " + (8 - servant.getUses()) + " uses of my services remaining.");
stage = 50;
} else if(npc.getId() != servant.getId()){
interpreter.sendDialogues(npc, npc.getId() == 4243 ? FacialExpression.NORMAL : null, "You already have someone working for you.", "Fire them first before hiring me.");
stage = 100;
}
}
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
HouseManager manager = player.getHouseManager();
Servant servant = manager.getServant();
ServantType type = ServantType.forId(npc.getId());
switch(stage) {
case 0:
options("What can you do?", "Tell me about your previous jobs.", "You're hired!");
stage++;
break;
case 1:
switch(buttonId) {
case 1: //TODO:
break;
case 2: //TODO:
break;
case 3:
player("You're hired!");
stage = 2;
break;
}
break;
case 2:
interpreter.sendDialogues(npc, npc.getId() == 4243 ? FacialExpression.NORMAL : null, "Alright, " + (player.getAppearance().isMale() ? "sir" : "ma'am") + ". I can start work immediately.");
stage++;
break;
case 3:
if (type != null && player.getInventory().getAmount(995) >= type.getCost() && player.getInventory().remove(new Item(995, type.getCost()))) {
manager.setServant(new Servant(type));
interpreter.sendDialogue("The servant heads to your house.");
stage = 100;
break;
}
interpreter.sendDialogue("You don't have enough money to pay the servant's hiring fee.");
stage = 100;
break;
case 50:
options("Go to the bank/sawmill...", "Misc...", "Stop following me.", "You're fired!");
stage++;
break;
case 51:
type = servant.getType();
switch(buttonId) {
case 1:
options(!servant.getAttributes().containsKey("con:lastfetch") ? "Repeat last fetch task" : "Fetch another " + (type.getCapacity() + " x " + ((Item) servant.getAttribute("con:lastfetch")).getName().toLowerCase()) + " (" + (servant.getAttribute("con:lastfetchtype")) + ")", "Go to the bank", "Go to the sawmill", "Pay wages (" + servant.getUses()+"/8 uses)");
stage++;
break;
case 2:
options("Greet guests", "Cook me something");
stage = 56;
break;
case 3:
player("Stop following me.");
if (servant.getPulseManager().isMovingPulse()) {
servant.getPulseManager().clear("movement");
}
stage = 100;
break;
case 4:
player("You're fired!");
stage = 75;
break;
}
break;
case 52:
switch(buttonId){
case 1:
if (!servant.getAttributes().containsKey("con:lastfetch")) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I haven't recently fetched anything from the bank or", "sawmill for you.");
stage = 50;
break;
} else {
if (servant.getAttribute("con:lastfetchtype") == "bank") {
bankFetch(player, (Item) servant.getAttribute("con:lastfetch"));
return true;
}
end();
sawmillRun(player, (Item) servant.getAttribute("con:lastfetch"));
}
break;
case 2:
options("Planks", "Oak planks", "Teak planks", "Mahogany planks", "More options");
stage = 60;
break;
case 3:
if (type == ServantType.MAID || type == ServantType.RICK) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I am unable to travel to the sawmill for you.");
stage = 100;
break;
}
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "Hand the logs to me and I will take them to the", "sawmill for you.");
stage = 100;
break;
case 4:
stage = 100;
if (servant.getUses() < 1) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "You have no need to pay me yet, I haven't performed", "any of my services for you.");
break;
}
if (!player.getInventory().containsItem(new Item(995, type.getCost()))) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "Thanks for the kind gesture, but you don't have enough", "money to pay me. I require " + type.getCost() + " coins every eight uses", "of my services.");
break;
}
if (player.getInventory().remove(new Item(995, type.getCost()))) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "Thank you very much.");
servant.setUses(0);
}
break;
}
break;
case 56:
switch(buttonId) {
case 1:
servant.setGreet(!servant.isGreet());
player("Please " + (servant.isGreet() ? "greet" : "do not greet") + " all new guests upon arrival.");
stage++;
break;
case 2:
if (type.getFood() == null) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I don't know any recipes.");
stage = 100;
break;
}
if (type.getFood().length > 1) {
options(type.getFood()[0].getName(), type.getFood()[1].getName(), "Nevermind.");
stage = 58;
} else {
options(type.getFood()[0].getName(), "Nevermind.");
stage = 59;
}
break;
}
break;
case 57:
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "Whatever you command.");
stage = 50;
break;
case 58:
if (player.getInventory().freeSlots() < 1) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I would love to share my fine cooking with you,", "but your hands are currently full.");
stage = 100;
break;
}
if (!prereqs(player, null, false)) {
end();
return true;
}
switch(buttonId) {
case 1:
player.getInventory().add(type.getFood()[0]);
stage = 50;
break;
case 2:
player.getInventory().add(type.getFood()[1]);
stage = 50;
break;
case 3:
player("Nevermind.");
stage = 100;
return true;
}
servant.setUses(servant.getUses() + 1);
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "Luckily for you, I already have some made. Here you", "go.");
stage = 50;
break;
case 59:
if (player.getInventory().freeSlots() < 1) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I would love to share my fine cooking with", "you, but you have no space to take anything.");
stage = 50;
break;
}
if (!prereqs(player, null, false)) {
end();
return true;
}
switch(buttonId) {
case 1:
player.getInventory().add(type.getFood()[0]);
stage = 100;
break;
case 2:
player("Nevermind.");
stage = 100;
return true;
}
servant.setUses(servant.getUses() + 1);
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "Luckily for you, I already have some made. Here you", "go.");
stage = 100;
break;
case 60:
switch(buttonId) {
case 1: //planks
bankFetch(player, new Item(960));
stage = 100;
break;
case 2: //oak
bankFetch(player, new Item(8778));
stage = 100;
break;
case 3: //teak
bankFetch(player, new Item(8780));
break;
case 4: //mahog
bankFetch(player, new Item(8782));
break;
case 5:
options("Soft clay", "Limestone bricks", "Steel bars", "Cloth", "More options");
stage++;
break;
}
break;
case 61:
switch(buttonId) {
case 1: //clay
bankFetch(player, new Item(1761));
break;
case 2: //lime
bankFetch(player, new Item(3420));
break;
case 3: //steel bars
bankFetch(player, new Item(2353));
break;
case 4: //cloth
bankFetch(player, new Item(8790));
break;
case 5:
options("Gold leaves", "Marble blocks", "Magic stones");
stage++;
break;
}
break;
case 62:
switch(buttonId) {
case 1: //leaves
bankFetch(player, new Item(4692));
break;
case 2: //marble
bankFetch(player, new Item(8786));
break;
case 3: //magic stones
bankFetch(player, new Item(4703));
break;
}
break;
case 75:
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "Very well. I will return to the Guild of the Servants", "in Ardougne if you wish to re-hire me.");
stage++;
break;
case 76:
end();
servant.getItem().setAmount(0);
servant.setUses(0);
servant.clear();
servant.setLocation(new Location(0, 0));
manager.setServant(null);
break;
case 100:
end();
break;
case 110:
end();
sawmillRun(player, logs);
break;
case 150:
if (servant.getItem()== null) {
end();
return true;
}
int amtLeft = servant.getItem().getAmount();
boolean flag = false;
if (amtLeft < 1 || servant.getItem() == null) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I don't have any items left.");
stage = 100;
break;
}
if (amtLeft > player.getInventory().freeSlots()) {
amtLeft = player.getInventory().freeSlots();
flag = true;
}
servant.getItem().setAmount(servant.getItem().getAmount() - amtLeft);
player.getInventory().add(new Item(servant.getItem().getId(), amtLeft));
if (flag) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I still have " + servant.getItem().getAmount() + " left for you to take from me.");
stage = 100;
} else{
end();
}
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 4235, 4237, 4239, 4241, 4243 };
}
/**
* Checks the pre-reqs for a sawmill run or a bank run.
* @param player
* @param item
* @return true or false if they have the requirements to use the servant.
*/
private boolean prereqs(final Player player, final Item item, boolean sawmill) {
HouseManager manager = player.getHouseManager();
Servant servant = manager.getServant();
if (!sawmill && player.getInventory().freeSlots() < 1) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "You don't have any space in your inventory.");
stage = 100;
return false;
}
if (servant.getUses() >= 8) {
player.sendMessage("<col=CC0000>The servant has left your service due to a lack of payment.</col>");
servant.getItem().setAmount(0);
servant.setUses(0);
servant.clear();
servant.setLocation(new Location(0, 0));
manager.setServant(null);
end();
return false;
}
if (servant.getItem().getAmount() > 0) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "You can't send me off again, I'm still holding some of", "your previous items.");
return false;
}
return true;
}
/**
* Goes to the sawmill.
* @param player
* @param item
*/
private void sawmillRun(final Player player, final Item item) {
HouseManager manager = player.getHouseManager();
final Servant servant = manager.getServant();
final ServantType type = manager.getServant().getType();
if (servant == null || item == null || !prereqs(player, item, true)) {
return;
}
if (type == ServantType.MAID || type == ServantType.RICK) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "I am unable to take planks to the sawmill.");
return;
}
int amt = player.getInventory().getAmount(item);
if (amt < 1) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "You don't have any more of that type of log.");
return;
}
for (Plank plank : Plank.values()) {
if (plank.getLog().getId() == item.getId()) {
if (amt > type.getCapacity()) {
amt = type.getCapacity();
}
if (!player.getInventory().contains(995, plank.getPrice() * amt)) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "You don't have enough coins for me to do that.", "I can hold " + type.getCapacity() + " logs and each of this type of log", "costs " + plank.getPrice() + " coins each to convert into plank form.");
return;
}
end();
if (player.getInventory().remove(new Item(item.getId(), amt)) && player.getInventory().remove(new Item(995, amt * plank.getPrice()))) {
manager.getServant().setItem(new Item(plank.getPlank().getId(), amt));
servant.setInvisible(true);
servant.getLocks().lockMovement(100);
GameWorld.submit(new Pulse((int) (type.getTimer() / 0.6)){
@Override
public boolean pulse() {
servant.setInvisible(false);
servant.getLocks().unlockMovement();
servant.setAttribute("con:lastfetch", new Item(item.getId(), 1));
servant.setAttribute("con:lastfetchtype", "sawmill");
interpreter.open(servant.getId(), servant);
return true;
}
});
}
break;
}
}
}
/**
* Gets items from the player's bank.
* @param player
* @param item
*/
private void bankFetch(final Player player, final Item item) {
final HouseManager manager = player.getHouseManager();
final Servant servant = manager.getServant();
final ServantType type = manager.getServant().getType();
if (servant == null || item == null || !prereqs(player, item, false)) {
return;
}
if (!player.getBank().containsItem(item)) {
interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.NORMAL : null, "You don't seem to have any of those in the bank.");
stage = 100;
return;
}
end();
servant.setInvisible(true);
servant.getLocks().lockMovement(100);
GameWorld.submit(new Pulse((int) (type.getTimer() / 0.6)) {
@Override
public boolean pulse() {
if (player == null || player.getHouseManager().getRegion() != player.getViewport().getRegion()) { //TODO: Check if in dungeon?
return true;
}
int amt = player.getBank().getAmount(item.getId());
if (amt < 1) {
return true;
}
if (amt > type.getCapacity()) {
amt = type.getCapacity();
}
servant.setInvisible(false);
servant.getLocks().unlockMovement();
Item fetch = new Item(item.getId(), amt);
if (player.getBank().remove(fetch)) {
manager.getServant().setItem(fetch);
interpreter.open(servant.getId(), servant);
}
servant.setAttribute("con:lastfetch", new Item(fetch.getId(), 1));
servant.setAttribute("con:lastfetchtype", "bank");
manager.getServant().setUses(manager.getServant().getUses() + 1);
follow(player, servant);
return true;
}
});
}
/**
* Follows the person who is talking to them.
* @param player
* @param npc
*/
private void follow(Player player, NPC npc) {
npc.getPulseManager().run(new MovementPulse(npc, player, Pathfinder.SMART) {
@Override
public boolean pulse() {
return false;
}
}, "movement");
}
}

View file

@ -0,0 +1,55 @@
package plugin.skill.construction.npc;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
/**
* Handles interaction with the house servant.
* @author Splinter
* @date 9/24/2015
* @version 0.1
*
* @see {@link HouseServantDialogue}
* For the other associated classes that deal with house servants.
*
*/
@InitializablePlugin
public class HouseServantPlugin extends UseWithHandler {
/**
* The item IDS to use.
*/
final static int[] IDS = { 1511, 1521, 6333, 6332 };
/**
* Constructs a new {@code HouseServantPlugin} {@code Object}.
*/
public HouseServantPlugin() {
super(IDS);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(4235, NPC_TYPE, this);
addHandler(4237, NPC_TYPE, this);
addHandler(4239, NPC_TYPE, this);
addHandler(4241, NPC_TYPE, this);
addHandler(4243, NPC_TYPE, this);
PluginManager.definePlugin(new HouseServantDialogue());
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
if (event.getUsedItem() == null || event.getUsedWith() == null) {
return true;
}
event.getPlayer().getDialogueInterpreter().open(event.getUsedWith().asNpc().getId(), event.getUsedWith().asNpc(), true, event.getUsedItem());
return true;
}
}

View file

@ -0,0 +1,78 @@
package plugin.skill.construction.npc;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.cache.def.impl.NPCDefinition;
import org.crandor.game.content.global.shop.Shop;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the Keldagrim Stonemason.
* @author Splinter
*/
@InitializablePlugin
public class StonemasonPlugin extends OptionHandler {
/**
* The store that sells supplies.
*/
private static final SupplyStore STORE = new SupplyStore();
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.forId(4248).getConfigurations().put("option:trade", this);
NPCDefinition.forId(4248).getConfigurations().put("option:talk-to", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (option) {
case "trade":
case "talk-to":
STORE.open(player);
break;
}
return true;
}
/**
* Stonemason's store.
* @author Splinter
*/
public static class SupplyStore extends Shop {
/**
* Constructs a new {@Code SupplyStore} {@Code Object}
*/
public SupplyStore() {
super("Keldagrim Stonemason", new Item[] { new Item(3420, 500_000), new Item(8786, 10_000), new Item(8784, 15_000), new Item(8788, 10_000) }, false);
}
@Override
public boolean canSell(Player player, Item item, ItemDefinition def) {
player.sendMessage("You cannot sell items to this store.");
return false;
}
@Override
public int getBuyPrice(Item item, Player player) {
switch (item.getId()) {
case 3420:
return 26;
case 8786:
return 325_000;
case 8784:
return 130_000;
case 8788:
return 975_000;
}
return -1;
}
}
}

View file

@ -0,0 +1,69 @@
package plugin.skill.cooking;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to make a cake.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class CakeMakingPlugin extends UseWithHandler {
/**
* Represents the bucket of milk item.
*/
private static final Item BUCKET_OF_MILK = new Item(1927);
/**
* Represents the egg item.
*/
private static final Item EGG = new Item(1944);
/**
* Represents the cake tin item.
*/
private static final Item CAKE_TIN = new Item(1887);
/**
* Represents the pot of flour item.
*/
private static final Item POT_OF_FLOUR = new Item(1933);
/**
* Represents the uncooked cake item.
*/
private static final Item UNCOOKED_CAKE = new Item(1889);
/**
* Constructs a new {@code CakeMakingPlugin} {@code Object}.
*/
public CakeMakingPlugin() {
super(1933);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(1887, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
if (event.getUsedItem().getId() == 1887 && ((Item) event.getUsedWith()).getId() == 1933 || event.getUsedWith().getName().equalsIgnoreCase("cake tin") && ((Item) event.getUsedItem()).getName().equalsIgnoreCase("pot of flour")) {
if (event.getPlayer().getInventory().contains(1933, 1) && event.getPlayer().getInventory().contains(1927, 1) && event.getPlayer().getInventory().contains(1944, 1)) {
if (event.getPlayer().getInventory().remove(BUCKET_OF_MILK, EGG, CAKE_TIN, POT_OF_FLOUR)) {
event.getPlayer().getInventory().add(UNCOOKED_CAKE);
event.getPlayer().getPacketDispatch().sendMessage("You mix the milk, flour and egg together to make a raw cake mix.");
return true;
}
}
}
return false;
}
}

View file

@ -0,0 +1,56 @@
package plugin.skill.cooking;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to make a coconut.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class CoconutMakePlugin extends UseWithHandler {
/**
* Represents the items related to coconut making plugin.
*/
private static final Item[] ITEMS = new Item[] { new Item(5974, 1), new Item(5976, 1), new Item(229), new Item(5935, 1), new Item(5978) };
/**
* Constructs a new {@code CoconutMakePlugin} {@code Object}.
*/
public CoconutMakePlugin() {
super(5974, 5976);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(2347, ITEM_TYPE, this);
addHandler(229, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final Item usedWith = (Item) event.getUsedWith();
if (usedWith.getId() == 5974 && event.getUsedItem().getId() == 2347 || usedWith.getId() == 2347 && event.getUsedItem().getId() == 5974) {
player.getInventory().remove(ITEMS[0]);
player.getInventory().add(ITEMS[1]);
player.getPacketDispatch().sendMessage("You crush the coconut with a hammer.");
}
if (usedWith.getId() == 5976 && event.getUsedItem().getId() == 229 || usedWith.getId() == 229 && event.getUsedItem().getId() == 5976) {
player.getInventory().remove(ITEMS[1]);
player.getInventory().remove(ITEMS[2]);
player.getInventory().add(ITEMS[3]);
player.getInventory().add(ITEMS[4]);
player.getPacketDispatch().sendMessage("You overturn the coconut into a vial.");
}
return true;
}
}

View file

@ -0,0 +1,157 @@
package plugin.skill.cooking;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.global.consumable.Consumables;
import org.crandor.game.content.global.consumable.Food;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.net.packet.PacketRepository;
import org.crandor.net.packet.context.ChildPositionContext;
import org.crandor.net.packet.out.RepositionChild;
import org.crandor.plugin.InitializablePlugin;
/**
* Represents the dialogue used to handle the amount to make of a cookable item.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class CookingDialoguePlugin extends DialoguePlugin {
/**
* Represents the cooking dialogue id.
*/
public static final int DIALOGUE_ID = 43989;
/**
* Represents the sinew item.
*/
private static final Item SINEW = new Item(9436);
/**
* Represents the meat item.
*/
private static final Item MEAT = new Item(2142);
/**
* Represents the food we're cooking.
*/
private Food food;
/**
* Represents the obejct we're cooking on.
*/
private GameObject object;
/**
* Constructs a new {@code CookingDialoguePlugin} {@code Object}.
*/
public CookingDialoguePlugin() {
/**
* empty.
*/
}
/**
* Constructs a new {@code CookingDialoguePlugin} {@code Object}.
* @param player the player.
*/
public CookingDialoguePlugin(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new CookingDialoguePlugin(player);
}
@Override
public boolean open(Object... args) {
food = ((Food) args[0]);
object = ((GameObject) args[1]);
if (args.length == 3) {
interpreter.sendOptions("Select an Option", "Dry the meat into sinew.", "Cook the meat.");
stage = 100;
return true;
}
if (player.getInventory().getAmount(food.getRaw()) == 1) {
end();
food.cook(player, object, 1);
return true;
}
display();
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
end();
int amount = getAmount(buttonId);
if (amount == -1) {
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int amount = (int) value;
food.cook(player, object, amount);
return false;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
}
food.cook(player, object, amount);
break;
case 100:
switch (buttonId) {
case 1:
food = Consumables.forFood(SINEW);
display();
break;
case 2:
food = Consumables.forFood(MEAT);
display();
break;
}
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { DIALOGUE_ID };
}
/**
* Method used to display the content food.
*/
public void display() {
player.getInterfaceManager().openChatbox(307);
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 307, 3, 60, 79));
player.getPacketDispatch().sendItemZoomOnInterface(food.getRaw().getId(), 160, 307, 2);
player.getPacketDispatch().sendString(food.getRaw().getName(), 307, 3);
stage = 0;
}
/**
* Method used to get the amount to make based off the button id.
* @param buttonId the button id.
* @return the amount to make.
*/
private final int getAmount(final int buttonId) {
switch (buttonId) {
case 5:
return 1;
case 4:
return 5;
case 3:
return -1;
}
return -1;
}
}

View file

@ -0,0 +1,70 @@
package plugin.skill.cooking;
import org.crandor.game.content.global.consumable.Consumables;
import org.crandor.game.content.global.consumable.Food;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Direction;
import org.crandor.game.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle the interaction of a cooking consumable
* with a range/fire.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class CookingPlugin extends UseWithHandler {
/**
* Represents the objects allowed to cook {@code Food} on.
*/
private static final int[] OBJECTS = new int[] { 21302, 13528, 13529, 13533, 13531, 13536, 13539, 13542, 2728, 2729, 2730, 2731, 2732, 2859, 3038, 3039, 3769, 3775, 4265, 4266, 5249, 5499, 5631, 5632, 5981, 9682, 10433, 11404, 11405, 11406, 12102, 12796, 13337, 13881, 14169, 14919, 15156, 20000, 20001, 21620, 21792, 22713, 22714, 23046, 24283, 24284, 25155, 25156, 25465, 25730, 27297, 29139, 30017, 32099, 33500, 34495, 34546, 36973, 37597, 37629, 37726, 114, 4172, 5275, 8750, 16893, 22154, 34410, 34565, 114, 9085, 9086, 9087, 12269, 15398, 25440, 25441, 2724, 2725, 2726, 4618, 4650, 5165, 6093, 6094, 6095, 6096, 8712, 9439, 9440, 9441, 10824, 17640, 17641, 17642, 17643, 18039, 21795, 24285, 24329, 27251, 33498, 35449, 36815, 36816, 37426 };
/**
* Constructs a new {@code CookingPlugin} {@code Object}.
*/
public CookingPlugin() {
super(2138, 2142, 2134, 3142, 2136, 1859, 3226, 7518, 3150, 327, 321, 345, 353, 335, 341, 349, 331, 3379, 359, 10138, 5001, 377, 363, 371, 2148, 7944, 383, 395, 389, 3363, 3365, 3367, 5986, 401, 1942, 4237, 2001, 7076, 1871, 7080, 2307, 1889, 2132, 2132, 2132, 2132, 2321, 2319, 7168, 2317, 7176, 7186, 7196, 7206, 7216, 2287, 317, 9986, 2876, 7566, 9984, 7224);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int object : OBJECTS) {
addHandler(object, OBJECT_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final GameObject object = (GameObject) event.getUsedWith();
final Food food = Consumables.forRaw(event.getUsedItem());
if (food == null || !food.interact(event.getPlayer(), object)) {
return true;
}
event.getPlayer().getDialogueInterpreter().open(43989, food, event.getUsedWith());
return true;
}
@Override
public Location getDestination(final Player player, final Node node) {
if (node.getName().toLowerCase().equals("fire")) {
return player.getLocation().getY() > node.getLocation().getY() ? node.getLocation().transform(0, 1, 0) : player.getLocation().getX() < node.getLocation().getX() ? node.getLocation().transform(-1, 0, 0) : player.getLocation().getX() > node.getLocation().getX() ? node.getLocation().transform(1, 0, 0) : node.getLocation().transform(0, -1, 0);
} else {
Direction direction = node.getDirection();
if (direction == Direction.NORTH) {
return node.getLocation().transform(1, 1, 0);
} else if (direction == Direction.SOUTH) {
return node.getLocation().transform(-1, 0, 0);
}
return null;
}
}
}

View file

@ -0,0 +1,103 @@
package plugin.skill.cooking;
import org.crandor.game.content.skill.free.cooking.recipe.Recipe;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
/**
* Represents a cooking recipe plugin. This is used to handle the multiple
* recipes used in cooking these recipes can range from making a pizza or making
* a pie.
* @author 'Vexia
* @version 1.9
*/
@InitializablePlugin
public final class CookingRecipePlugin extends UseWithHandler {
/**
* Constructs a new {@code CookingRecipePlugin} {@code Object}.
*/
public CookingRecipePlugin() {
super(getAllowedNodes());
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Recipe recipe : Recipe.RECIPES) {
for (Item ingredient : recipe.getIngredients()) {
addHandler(ingredient.getId(), ITEM_TYPE, this);
}
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
Recipe recipe = null;
for (Recipe temp : Recipe.RECIPES) {
if (temp.isSingular()) {
if (temp.getBase().getId() == event.getUsedItem().getId() || temp.getBase().getId() == event.getBaseItem().getId()) {
for (Item ingredient : temp.getIngredients()) {
if (ingredient.getId() == event.getBaseItem().getId() || ingredient.getId() == event.getUsedItem().getId()) {
recipe = temp;
break;
}
}
}
} else {
Item part = null;
Item ingredient = null;
for (int k = 0; k < temp.getParts().length; k++) {
for (int i = 0; i < temp.getIngredients().length; i++) {
part = temp.getParts()[k];
ingredient = temp.getIngredients()[i];
if (part.getId() == event.getUsedItem().getId() && ingredient.getId() == event.getBaseItem().getId() || part.getId() == event.getBaseItem().getId() && ingredient.getId() == event.getUsedItem().getId()) {
if (k == i) {// represents that this ingredient can
// mix with the other.
recipe = temp;
break;
}
}
}
}
}
}
if (recipe != null) {
recipe.mix(event.getPlayer(), event);
return true;
}
return false;
}
/**
* Method used to get the allowed nodes for this plugin.
* @return the allowed nodes.
*/
private final static int[] getAllowedNodes() {
List<Integer> bases = new ArrayList<>();
for (Recipe recipe : Recipe.RECIPES) {
for (Item base : recipe.getParts()) {
if (bases.contains(base.getId())) {
continue;
}
bases.add(base.getId());
}
if (bases.contains(recipe.getBase().getId())) {
continue;
}
bases.add(recipe.getBase().getId());
}
int[] baseArray = new int[bases.size()];
for (int i = 0; i < bases.size(); i++) {
baseArray[i] = bases.get(i);
}
return baseArray;
}
}

View file

@ -0,0 +1,34 @@
package plugin.skill.cooking;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used for the fire pottery object.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class FireOptionPotteryPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(2643).getConfigurations().put("option:fire", this);
ObjectDefinition.forId(4308).getConfigurations().put("option:fire", this);
ObjectDefinition.forId(11601).getConfigurations().put("option:fire", this);
ObjectDefinition.forId(34802).getConfigurations().put("option:fire", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.faceLocation(node.getLocation());
player.getDialogueInterpreter().open(99843, true, true);
return true;
}
}

View file

@ -0,0 +1,160 @@
package plugin.skill.cooking;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.global.tutorial.TutorialSession;
import org.crandor.game.content.global.tutorial.TutorialStage;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to make dough.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class MakeDoughPlugin extends UseWithHandler {
/**
* Represents the water sources.
*/
private static final Item[][] SOURCES = new Item[][] { { new Item(1929), new Item(1925) }, { new Item(1921), new Item(1923) }, { new Item(1937), new Item(1935) } };
/**
* Constructs a new {@code MakeDoughPlugin} {@code Object}.
*/
public MakeDoughPlugin() {
super(1933);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i = 0; i < SOURCES.length; i++) {
addHandler(SOURCES[i][0].getId(), ITEM_TYPE, this);
}
new MakeDoughDialogue().init();
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
if (player.getAttributes().containsKey("tut-island")) {
return handleTutorialIsland(player, event);
}
Item[] data = null;
for (int i = 0; i < SOURCES.length; i++) {
if (SOURCES[i][0].getId() == event.getUsedItem().getId() || SOURCES[i][0].getId() == event.getBaseItem().getId()) {
data = SOURCES[i];
break;
}
}
player.getDialogueInterpreter().open(59 << 16 | 1, (Object) data);
return false;
}
/**
* Method used to handle the tutorial isalnd making dough.
* @param player the player.
* @param event the event.
*/
private boolean handleTutorialIsland(final Player player, final NodeUsageEvent event) {
if (player.getInventory().freeSlots() == 0) {
player.getPacketDispatch().sendMessage("You don't have enough inventory space.");
return true;
}
player.lock(3);
player.getInventory().remove(event.getBaseItem(), new Item(1933, 1));
player.getInventory().add(new Item(3727, 1), new Item(1931, 1), new Item(2307, 1));
if (TutorialSession.getExtension(player).getStage() == 19) {
TutorialStage.load(player, 20, false);
}
return true;
}
/**
* Represents the plugin used to make dough..
* @author 'Vexia
* @version 1.0
*/
public static final class MakeDoughDialogue extends DialoguePlugin {
/**
* Represents the dough items to make.
*/
private static final Item[] DOUGHS = new Item[] { new Item(2307), new Item(1953), new Item(2283), new Item(1863) };
/**
* Represents the pot of flour item.
*/
private static final Item FLOUR = new Item(1933);
/**
* Represents the water source data.
*/
private Item[] waterData;
/**
* Constructs a new {@code MakeDoughDialogue} {@code Object}.
*/
public MakeDoughDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code MakeDoughDialogue} {@code Object}.
* @param player the player.
*/
public MakeDoughDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new MakeDoughDialogue(player);
}
@Override
public boolean open(Object... args) {
waterData = (Item[]) args[0];
interpreter.sendOptions("What do you wish to make?", "Bread dough.", "Pastry dough.", "Pizza dough.", "Pitta dough.");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
makeDough(DOUGHS[buttonId - 1]);
end();
break;
}
return true;
}
/**
* Method used to make a dough item.
* @param dough the dough.
*/
private void makeDough(final Item dough) {
if (player.getInventory().remove(waterData[0]) && player.getInventory().remove(FLOUR)) {
player.getInventory().add(waterData[1]);
player.getInventory().add(dough);
player.getInventory().add(new Item(1931), player);
player.getPacketDispatch().sendMessage("You mix the flower and water to make some " + dough.getName().toLowerCase() + ".");
}
}
@Override
public int[] getIds() {
return new int[] { 59 << 16 | 1 };
}
}
}

View file

@ -0,0 +1,62 @@
package plugin.skill.cooking;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the stew plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public class MakeStewPlugin extends UseWithHandler {
/**
* Constructs a new {@code MakeStewPlugin} {@code Object}.
*/
public MakeStewPlugin() {
super(2001);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(114, OBJECT_TYPE, this);
addHandler(2728, OBJECT_TYPE, this);
addHandler(2729, OBJECT_TYPE, this);
addHandler(2730, OBJECT_TYPE, this);
addHandler(2731, OBJECT_TYPE, this);
addHandler(2859, OBJECT_TYPE, this);
addHandler(3039, OBJECT_TYPE, this);
addHandler(4172, OBJECT_TYPE, this);
addHandler(5275, OBJECT_TYPE, this);
addHandler(8750, OBJECT_TYPE, this);
addHandler(9682, OBJECT_TYPE, this);
addHandler(12102, OBJECT_TYPE, this);
addHandler(14919, OBJECT_TYPE, this);
addHandler(16893, OBJECT_TYPE, this);
addHandler(21792, OBJECT_TYPE, this);
addHandler(22154, OBJECT_TYPE, this);
addHandler(22713, OBJECT_TYPE, this);
addHandler(22714, OBJECT_TYPE, this);
addHandler(24283, OBJECT_TYPE, this);
addHandler(24284, OBJECT_TYPE, this);
addHandler(25730, OBJECT_TYPE, this);
addHandler(33500, OBJECT_TYPE, this);
addHandler(34410, OBJECT_TYPE, this);
addHandler(34495, OBJECT_TYPE, this);
addHandler(34546, OBJECT_TYPE, this);
addHandler(34565, OBJECT_TYPE, this);
addHandler(36973, OBJECT_TYPE, this);
addHandler(37629, OBJECT_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
event.getPlayer().getDialogueInterpreter().open(43989, event.getUsedItem().getId(), "stew");
return true;
}
}

View file

@ -0,0 +1,61 @@
package plugin.skill.cooking;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to create nettle tea in a cup.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class NettleTeaPlugin extends UseWithHandler {
/**
* Represents the empty cup item.
*/
private static final Item EMPTY_CUP = new Item(1980, 1);
/**
* Represents the nettle tea item.
*/
private static final Item NETTLE_TEA = new Item(4239, 1);
/**
* Represents the bowl item.
*/
private static final Item BOWL = new Item(1923);
/**
* Represents the cup of tea item.
*/
private static final Item CUP_OF_TEA = new Item(4242, 1);
/**
* Constructs a new {@code NettleTeaPlugin} {@code Object}.
*/
public NettleTeaPlugin() {
super(1980);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(4239, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
if (player.getInventory().remove(EMPTY_CUP) && player.getInventory().remove(NETTLE_TEA)) {
player.getInventory().add(BOWL);
player.getInventory().add(CUP_OF_TEA);
}
return true;
}
}

View file

@ -0,0 +1,35 @@
package plugin.skill.cooking;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* @author Adam
*/
@InitializablePlugin
public class NettleWaterPlugin extends UseWithHandler {
public NettleWaterPlugin() {
super(1921);
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
player.getInventory().remove(new Item(1921, 1));
player.getInventory().remove(new Item(4241, 1));
player.getInventory().add(new Item(4237, 1));
return true;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(4241, ITEM_TYPE, this);
return this;
}
}

View file

@ -0,0 +1,56 @@
package plugin.skill.cooking;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the pie shell making plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class PieShellPlugin extends UseWithHandler {
/**
* Represents the pie sell item.
*/
private static final Item PIE_SHELL = new Item(2315, 1);
/**
* Represents the pie dish item.
*/
private static final Item PIE_DISH = new Item(2313, 1);
/**
* Represents the pastry dough item.
*/
private static final Item PASTRY_DOUGH = new Item(1953, 1);
/**
* Constructs a new {@code PieMakingPlugin} {@code Object}.
*/
public PieShellPlugin() {
super(1953);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(2313, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
if (player.getInventory().remove(PASTRY_DOUGH, PIE_DISH)) {
player.getInventory().add(PIE_SHELL);
player.getPacketDispatch().sendMessage("You put the pastry dough into the pie dish to make a pie shell.");
}
return true;
}
}

View file

@ -0,0 +1,111 @@
package plugin.skill.cooking;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to make skwered items.
* @author 'Vexia
* @date 22/12/2013
*/
@InitializablePlugin
public class SkeweredFoodPlugin extends UseWithHandler {
/**
* Represents the level required.
*/
private final int LEVEL = 20;
/**
* Constructs a new {@code SkeweredFoodPlugin} {@code Object}.
*/
public SkeweredFoodPlugin() {
super(7225);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (SkeweredSet set : SkeweredSet.values()) {
addHandler(set.getRaw().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
if (player.getSkills().getLevel(Skills.FIREMAKING) < LEVEL) {
player.getPacketDispatch().sendMessage("You meed a Firemaking level of at least " + LEVEL + " in order to do this.");
return true;
}
final SkeweredSet set = SkeweredSet.forItem(event.getBaseItem().getId() == 7225 ? event.getUsedItem() : event.getBaseItem());
if (player.getInventory().remove(event.getBaseItem()) && player.getInventory().remove(event.getUsedItem())) {
player.getInventory().add(set.getProduct());
}
return true;
}
/**
* Represents a set of skwered items.
* @author 'Vexia
* @date 22/12/2013
*/
public enum SkeweredSet {
RABBIT(new Item(3226), new Item(7224)), CHOMPY(new Item(2876), new Item(7230)), BIRD(new Item(9978), new Item(9984)), BEAST(new Item(9986), new Item(9992));
/**
* Represents the raw item.
*/
private final Item raw;
/**
* Represents the product item.
*/
private final Item product;
/**
* Constructs a new {@code SkeweredFoodPlugin} {@code Object}.
* @param raw the raw item.
* @param product the product.
*/
private SkeweredSet(Item raw, Item product) {
this.raw = raw;
this.product = product;
}
/**
* Gets the raw.
* @return The raw.
*/
public Item getRaw() {
return raw;
}
/**
* Gets the product.
* @return The product.
*/
public Item getProduct() {
return product;
}
/**
* Gets the skwered set.
* @param item the item.
* @return the set.
*/
public static SkeweredSet forItem(final Item item) {
for (SkeweredSet set : values()) {
if (set.getRaw().getId() == item.getId()) {
return set;
}
}
return null;
}
}
}

View file

@ -0,0 +1,59 @@
package plugin.skill.cooking;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.item.GroundItemManager;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to slice a watermelon.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class WatermelonSlicePlugin extends UseWithHandler {
/**
* Represents the knife item.
*/
private static final Item KNIFE = new Item(946);
/**
* Represents the watermelon item.
*/
private static final Item WATERMELON = new Item(5982);
/**
* Represents the watermelon slice item.
*/
private static final Item WATERMELON_SLICE = new Item(5984);
/**
* Constructs a new {@code WatermelonSlicePlugin.java} {@code Object}.
*/
public WatermelonSlicePlugin() {
super(KNIFE.getId());
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(5982, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
if (event.getPlayer().getInventory().remove(WATERMELON)) {
for (int i = 0; i < 3; i++) {
if (!event.getPlayer().getInventory().add(WATERMELON_SLICE)) {
GroundItemManager.create(WATERMELON_SLICE, event.getPlayer());
}
}
event.getPlayer().getPacketDispatch().sendMessage("You slice the watermelon into three slices.");
}
return true;
}
}

View file

@ -0,0 +1,63 @@
package plugin.skill.cooking;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.free.cooking.fermenting.WineFermentingPulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.GameWorld;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to ferment wine.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class WineFermentPlugin extends UseWithHandler {
/**
* Represents the grapes item.
*/
private static final Item GRAPES = new Item(1987, 1);
/**
* Represents the jug of water item.
*/
private static final Item JUG_OF_WATER = new Item(1937, 1);
/**
* Represents the unfermented wine item.
*/
private static final Item UNFERMENTED_WINE = new Item(1995, 1);
/**
* Constructs a new {@code WineFermentPlugin} {@code Object}.
*/
public WineFermentPlugin() {
super(1937);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(1987, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
if (player.getSkills().getLevel(Skills.COOKING) < 35) {
player.getPacketDispatch().sendMessage("You need a cooking level of 35 to do this.");
return true;
}
if (player.getInventory().remove(GRAPES, JUG_OF_WATER)) {
player.getInventory().add(UNFERMENTED_WINE);
GameWorld.submit(new WineFermentingPulse(1, player));
}
return true;
}
}

View file

@ -0,0 +1,50 @@
package plugin.skill.crafting;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.free.crafting.jewellery.JewelleryCrafting;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to string an amulet.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class AmuletStringingPlugin extends UseWithHandler {
/**
* Constructs a new {@code AmuletStringingPlugin} {@code Object}.
*/
public AmuletStringingPlugin() {
super(1673, 1675, 1677, 1679, 1681, 1683, 6579);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(1759, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final JewelleryCrafting.JewelleryItem data = JewelleryCrafting.JewelleryItem.forProduct(event.getUsedItem().getId() == 6579 ? 6579 : ((Item) event.getUsedWith()).getId());
if (data == null) {
return true;
}
if (player.getSkills().getLevel(Skills.CRAFTING) < data.getLevel()) {
player.getPacketDispatch().sendMessage("You need a Crafting level of at least " + data.getLevel() + " to do that.");
return true;
}
if (player.getInventory().remove(event.getUsedItem(), event.getBaseItem())) {
player.getInventory().add(new Item(data == JewelleryCrafting.JewelleryItem.ONYX_AMULET ? 6581 : data.getSendItem() + 19));
}
return true;
}
}

View file

@ -0,0 +1,62 @@
package plugin.skill.crafting;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.free.crafting.BattleStaves;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the battle stave making plugin used for zaff.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class BattlestaveMakePlugin extends UseWithHandler {
/**
* Represents the original staff item.
*/
private static final Item STAFF = new Item(1391, 1);
/**
* Constructs a new {@code BattlestaveMakePlugin} {@code Object}.
*/
public BattlestaveMakePlugin() {
super(STAFF.getId(), 573, 571, 575, 569);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(573, ITEM_TYPE, this);
addHandler(571, ITEM_TYPE, this);
addHandler(575, ITEM_TYPE, this);
addHandler(569, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
if (event.getUsedItem().getId() != STAFF.getId()) {
return false;
}
int id = event.getUsedItem().getId() == STAFF.getId() ? event.getUsedWith().getId() : event.getUsedItem().getId();
final BattleStaves staff = BattleStaves.forId(id);
if (staff == null)
return true;
if (player.getSkills().getLevel(Skills.CRAFTING) < staff.getLevel()) {
player.getPacketDispatch().sendMessage("You need a crafting level of " + staff.getLevel() + " to make this.");
return true;
}
player.getInventory().remove(STAFF);
player.getInventory().remove(new Item(staff.getObelisk(), 1));
player.getInventory().add(new Item(staff.getProduct(), 1));
player.getSkills().addExperience(Skills.CRAFTING, staff.getExp(), true);
return true;
}
}

View file

@ -0,0 +1,45 @@
package plugin.skill.crafting;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the bullseye lantern crafting.
* @author Vexia
*
*/
@InitializablePlugin
public class BullseyeLanternPlugin extends UseWithHandler {
/**
* Constructs the {@code BullseyeLanternPlugin}
*/
public BullseyeLanternPlugin() {
super(4542, 1607);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(4544, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final Item with = event.getUsedWith().asItem();
int rewardId = 4546;
if (with.getId() == 1607) {
rewardId = 4700;
}
if (player.getInventory().remove(event.getUsedItem())) {
player.getInventory().replace(new Item(rewardId), event.getUsedWith().asItem().getSlot());
}
return true;
}
}

View file

@ -0,0 +1,58 @@
package plugin.skill.crafting;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.free.crafting.gem.GemCutPulse;
import org.crandor.game.content.skill.free.crafting.gem.Gems;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to cut a gem.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class GemCutPlugin extends UseWithHandler {
/**
* Constructs a new {@code GemCutPlugin} {@Code Object}
*/
public GemCutPlugin() {
super(1623, 1621, 1619, 1617, 1631, 6571, 1625, 1627, 1629, 6571);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(1755, ITEM_TYPE, this);
return null;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final Gems gem = Gems.forId(event.getUsedItem().getId() == 1755 ? event.getBaseItem() : event.getUsedItem());
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, gem.getGem()) {
@Override
public void create(final int amount, int index) {
player.getPulseManager().run(new GemCutPulse(player, gem.getUncut(), amount, gem));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(gem.getUncut());
}
};
if (player.getInventory().getAmount(gem.getUncut()) == 1) {
handler.create(0, 1);
} else {
handler.open();
}
return true;
}
}

View file

@ -0,0 +1,43 @@
package plugin.skill.crafting;
import org.crandor.game.content.skill.free.crafting.jewellery.JewelleryCrafting;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to craft jewellery.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class JewelleryCraftPlugin extends UseWithHandler {
/**
* Represents the ids to use for this plugin.
*/
private static final int[] IDS = new int[] { 4304, 6189, 11010, 11666, 12100, 12809, 18497, 26814, 30021, 30510, 36956, 37651 };
/**
* Constructs a new {@code JewelleryCraftPlugin} {@code Object}.
*/
public JewelleryCraftPlugin() {
super(2357);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i : IDS) {
addHandler(i, OBJECT_TYPE, this);
}
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
JewelleryCrafting.open(event.getPlayer());
return true;
}
}

View file

@ -0,0 +1,121 @@
package plugin.skill.crafting;
import org.crandor.game.content.skill.SkillPulse;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to make molten glass.
* @author Vexia
* @author Splinter
* @version 1.0
*/
@InitializablePlugin
public final class MoltenGlassMakePlugin extends UseWithHandler {
/**
* Constructs a new {@code MoltenGlassMakePlugin} {@code Object}.
*/
public MoltenGlassMakePlugin() {
super(1783, 1781);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(4304, OBJECT_TYPE, this);
addHandler(6189, OBJECT_TYPE, this);
addHandler(11010, OBJECT_TYPE, this);
addHandler(11666, OBJECT_TYPE, this);
addHandler(12100, OBJECT_TYPE, this);
addHandler(12809, OBJECT_TYPE, this);
addHandler(18497, OBJECT_TYPE, this);
addHandler(26814, OBJECT_TYPE, this);
addHandler(30021, OBJECT_TYPE, this);
addHandler(30510, OBJECT_TYPE, this);
addHandler(36956, OBJECT_TYPE, this);
addHandler(37651, OBJECT_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
event.getPlayer().getPulseManager().run(new MoltenGlassPulse(event.getPlayer(), event.getUsedItem()));
return true;
}
/**
* Represents the pulse for molten glass making via a furnace
* @author Splinter
*/
public static class MoltenGlassPulse extends SkillPulse<Item> {
/**
* Represents the bucket of sand item.
*/
private static final Item BUCKET_OF_SAND = new Item(1783);
/**
* Represents the soda ash item.
*/
private static final Item SODA_ASH = new Item(1781);
/**
* Represents the molten glass item.
*/
private static final Item MOLTEN_GLASS = new Item(1775);
/**
* Represents the bucket item.
*/
private static final Item BUCKET = new Item(1925);
/**
* Constructs a new {@code MoltenGlassPulse} {@code Object}.
* @param player the player.
* @param node the node.
* @param amount the amount.
*/
public MoltenGlassPulse(Player player, Item node) {
super(player, node);
}
@Override
public boolean checkRequirements() {
if (player.getInventory().contains(1783, 1) && player.getInventory().contains(1781, 1)) {
return true;
}
player.sendMessage("You need at least one heap of soda ash and one bucket of sand to do this.");
return false;
}
@Override
public void animate() {
player.animate(Animation.create(899));
}
@Override
public boolean reward() {
if (getDelay() == 1) {
super.setDelay(3);
return false;
}
if (player.getInventory().remove(BUCKET_OF_SAND, SODA_ASH)) {
player.lock(3);
player.getInventory().add(MOLTEN_GLASS, BUCKET);
player.getSkills().addExperience(Skills.CRAFTING, 20, true);
player.sendMessage("You heat the sand and soda ash in the furnace to make glass.");
} else {
return true;
}
return false;
}
}
}

View file

@ -0,0 +1,164 @@
package plugin.skill.crafting;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.free.crafting.pottery.FirePotteryPulse;
import org.crandor.game.content.skill.free.crafting.pottery.PotteryItem;
import org.crandor.game.content.skill.free.crafting.pottery.PotteryPulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle pottery actions.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class PotteryPlugin extends UseWithHandler {
/**
* Represents the soft clay item.
*/
private static final Item SOFT_CLAY = new Item(1761);
/**
* Represents the oven ids.
*/
private static final int[] OVENS = new int[] { 2643, 4308, 11601, 34802 };
/**
* Constructs a new {@code PotteryPlugin} {@code Object}.
*/
public PotteryPlugin() {
super(1761);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
new FireOvenPlugin().newInstance(arg);
addHandler(2642, OBJECT_TYPE, this);
addHandler(2643, OBJECT_TYPE, this);
addHandler(4308, OBJECT_TYPE, this);
addHandler(4310, OBJECT_TYPE, this);
addHandler(20375, OBJECT_TYPE, this);
addHandler(34801, OBJECT_TYPE, this);
addHandler(34802, OBJECT_TYPE, this);
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
final Player player = event.getPlayer();
new SkillDialogueHandler(player, SkillDialogue.FIVE_OPTION, (Object[]) getPottery(false)) {
@Override
public void create(final int amount, int index) {
player.getPulseManager().run(new PotteryPulse(player, event.getUsedItem(), amount, PotteryItem.values()[index]));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(SOFT_CLAY);
}
}.open();
return true;
}
/**
* Gets the pottery items.
* @param finished if not.
* @return the items.
*/
private Item[] getPottery(boolean finished) {
final Item[] items = new Item[PotteryItem.values().length];
for (int i = 0; i < items.length; i++) {
items[i] = finished ? PotteryItem.values()[i].getProduct() : PotteryItem.values()[i].getUnfinished();
}
return items;
}
/**
* Represents the fire oven plugin.
* @author 'Vexia
* @version 1.0
*/
public class FireOvenPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int id : OVENS) {
ObjectDefinition.forId(id).getConfigurations().put("option:fire", this);
}
new FireUseHandler().newInstance(arg);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
getSkillHandler(player).open();
return true;
}
/**
* Represents the fire use with handler.
* @author 'Vexia
* @version 1.0
*/
public final class FireUseHandler extends UseWithHandler {
/**
* Constructs a new {@code FireUseHandler} {@code Object}.
*/
public FireUseHandler() {
super(1787, 1789, 1791, 5352, 4438);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(2643, OBJECT_TYPE, this);
addHandler(4308, OBJECT_TYPE, this);
addHandler(11601, OBJECT_TYPE, this);
addHandler(34802, OBJECT_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
getSkillHandler(player).open();
return true;
}
}
/**
* Gets the skill handler dialogue.
* @param player the player.
* @return the dialogue handler.
*/
public SkillDialogueHandler getSkillHandler(final Player player) {
return new SkillDialogueHandler(player, SkillDialogue.FIVE_OPTION, (Object[]) getPottery(true)) {
@Override
public void create(final int amount, final int index) {
player.getPulseManager().run(new FirePotteryPulse(player, PotteryItem.values()[index].getUnfinished(), PotteryItem.values()[index], amount));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(PotteryItem.values()[index].getUnfinished());
}
};
}
}
}

View file

@ -0,0 +1,50 @@
package plugin.skill.crafting;
import org.crandor.game.content.skill.free.crafting.SilverProduct;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to string jewelry.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class SilverStringingPlugin extends UseWithHandler {
/**
* Constructs a new {@code SilverStringingPlugin} {@code Object}.
*/
public SilverStringingPlugin() {
super(1714, 1720);
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
SilverProduct silver = null;
if (event.getUsedItem().getId() != 1759) {
silver = SilverProduct.forProductId(event.getUsedItem().getId());
} else if (((Item) event.getUsedWith()).getId() != 1759) {
silver = SilverProduct.forProductId((((Item) event.getUsedWith()).getId()));
}
if (silver == null) {
return true;
}
player.getInventory().remove(new Item(silver.getProduct(), 1));
player.getInventory().remove(new Item(1759, 1));
player.getInventory().add(new Item(silver.getStrung(), 1));
return true;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(1759, ITEM_TYPE, this);
return null;
}
}

View file

@ -0,0 +1,70 @@
package plugin.skill.crafting;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.free.crafting.armour.SnakeSkin;
import org.crandor.game.content.skill.free.crafting.armour.SnakeSkinPulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles snake skin plugin.
* @author Vexia
*/
@InitializablePlugin
public class SnakeSkinPlugin extends UseWithHandler {
/**
* Constructs a new {@Code SnakeSkinPlugin} {@Code Object}
*/
public SnakeSkinPlugin() {
super(1733);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(6289, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
final Player player = event.getPlayer();
new SkillDialogueHandler(player, SkillDialogue.FIVE_OPTION, (Object[]) getSkins()) {
@Override
public void create(final int amount, int index) {
player.getPulseManager().run(new SnakeSkinPulse(player, event.getUsedItem(), amount, SnakeSkin.values()[index]));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(new Item(6289));
}
@Override
public String getName(Item item) {
return item.getId() == 6328 ? "Boots" : item.getId() == 6330 ? "Vambs" : item.getId() == 6326 ? "Bandana" : item.getId() == 6324 ? "Chaps" : "Body";
}
}.open();
return true;
}
/**
* Gets the skins.
* @return the item.
*/
public Item[] getSkins() {
Item[] items = new Item[SnakeSkin.values().length];
for (int i = 0; i < items.length; i++) {
items[i] = SnakeSkin.values()[i].getProduct();
}
return items;
}
}

View file

@ -0,0 +1,111 @@
package plugin.skill.crafting;
import org.crandor.game.content.skill.SkillPulse;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the crafting of a snelm helmet.
* @author Vexia
*/
@InitializablePlugin
public class SnelmCraftPlugin extends UseWithHandler {
/**
* The snelm data.
*/
private static final int[][] DATA = new int[][] { { 3345, 3327 }, { 3355, 3337 },// blamish
{ 3349, 3341 }, { 3341, 3359 },// ochre
{ 3347, 3329 }, { 3357, 3339 },// blood
{ 3351, 3333 }, { 3361, 3343 },// blue
{ 3353, 3335 },// bark
};
/**
* Constructs a new {@Code SnelmCraftPlugin} {@Code Object}
*/
public SnelmCraftPlugin() {
super(1755);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i = 0; i < DATA.length; i++) {
for (int k = 0; k < DATA[i].length; k++) {
addHandler(DATA[i][0], ITEM_TYPE, this);
}
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
int[] snelm = null;
for (int i = 0; i < DATA.length; i++) {
for (int k = 0; k < DATA[i].length; k++) {
if (DATA[i][0] == event.getUsedItem().getId()) {
snelm = DATA[i];
break;
}
}
}
if (snelm == null) {
return false;
}
player.lock(1);
player.getPulseManager().run(new SnelmCraftPulse(player, event.getUsedItem(), snelm));
return true;
}
/**
* Handles the crafting of a snelm helmet.
* @author Vexia
*/
public static final class SnelmCraftPulse extends SkillPulse<Item> {
/**
* The snelm data.
*/
private final int[] data;
/**
* Constructs a new {@Code SnelmCraftPulse} {@Code Object}
* @param player the player.
* @param node the node.
*/
public SnelmCraftPulse(Player player, Item node, int[] data) {
super(player, node);
this.setDelay(1);
this.data = data;
}
@Override
public boolean checkRequirements() {
if (player.getSkills().getStaticLevel(Skills.CRAFTING) < 15) {
player.sendMessage("You need a Crafting level of at least 15 in order to do this.");
return false;
}
return true;
}
@Override
public void animate() {
}
@Override
public boolean reward() {
player.sendMessage("You craft the shell into a helmet.");
player.getInventory().replace(new Item(data[1]), node.getSlot());
player.getSkills().addExperience(Skills.CRAFTING, 32.5, true);
return true;
}
}
}

View file

@ -0,0 +1,45 @@
package plugin.skill.crafting;
import org.crandor.game.component.Component;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* The Stitch Crafting Plugin
* @author SonicForce41
*/
@InitializablePlugin
public class StitchCraftPlugin extends UseWithHandler {
/**
* Constructs a new {@code StitchCraftPlugin.java} {@Code Object}
*/
public StitchCraftPlugin() {
super(1741);
}
/**
* Method handles the actions for this Plugin
*/
@Override
public boolean handle(NodeUsageEvent event) {
Player player = event.getPlayer();
int itemId = event.getUsedItem().getId();
player.getAttributes().put("leatherId", itemId);
player.getInterfaceManager().open(new Component(154));
return true;
}
/**
* Method returns the instance for plugin
*/
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(1733, ITEM_TYPE, this);
return null;
}
}

View file

@ -0,0 +1,244 @@
package plugin.skill.crafting;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.SkillPulse;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the studded body plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class StuddedArmourPlugin extends UseWithHandler {
/**
* Represents the steel studs item.
*/
private static final Item STEEL_STUDS = new Item(2370);
/**
* Constructs a new {@code StuddedBodyPlugin} {@code Object}.
*/
public StuddedArmourPlugin() {
super(2370);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (StuddedArmour armour : StuddedArmour.values()) {
addHandler(armour.getItem().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
final Player player = event.getPlayer();
final StuddedArmour armour = StuddedArmour.forItem(event.getBaseItem());
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, armour.getStudded()) {
@Override
public void create(int amount, int index) {
player.getPulseManager().run(new StudArmourPulse(player, event.getBaseItem(), armour, amount));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(STEEL_STUDS);
}
};
if (player.getInventory().getAmount(armour.getItem()) == 1) {
handler.create(1, 0);
} else {
handler.open();
}
return true;
}
/**
* Represents a studded armour.
* @author 'Vexia
* @version 1.0
*/
public enum StuddedArmour {
CHAPS(new Item(1095), new Item(1097), 18, 27), BODY(new Item(1129), new Item(1133), 14, 25);
/**
* Represents the unstudded item.
*/
private final Item item;
/**
* Represents the studded item.
*/
private final Item studded;
/**
* Represents the level needed.
*/
private final int level;
/**
* Represents the experience gained.
*/
private final double experience;
/**
* Constructs a new {@code StuddedArmour} {@code Object}.
* @param item the item.
* @param studded the studded item.
* @param level the level.
* @param experience the experience.
*/
private StuddedArmour(Item item, Item studded, int level, double experience) {
this.item = item;
this.studded = studded;
this.level = level;
this.experience = experience;
}
/**
* Gets the studded armour for the item.
* @param item the item.
* @return the studden armour.
*/
public static StuddedArmour forItem(final Item item) {
for (StuddedArmour armour : values()) {
if (armour.getItem().getId() == item.getId()) {
return armour;
}
}
return null;
}
/**
* Gets the item.
* @return The item.
*/
public Item getItem() {
return item;
}
/**
* Gets the studded.
* @return The studded.
*/
public Item getStudded() {
return studded;
}
/**
* Gets the level.
* @return The level.
*/
public int getLevel() {
return level;
}
/**
* Gets the experience.
* @return The experience.
*/
public double getExperience() {
return experience;
}
}
/**
* Represents the skill pulse used to stud armour.
* @author 'Vexia
* @version 1.0
*/
public static final class StudArmourPulse extends SkillPulse<Item> {
/**
* Represents the animation to use.
*/
private static final Animation ANIMATION = Animation.create(1249);
/**
* Represents the armour being studded.
*/
private final StuddedArmour armour;
/**
* Represents the amount to make.
*/
private int amount;
/**
* Represents the ticks passed.
*/
private int ticks;
/**
* Constructs a new {@code StudArmourPulse} {@code Object}.
* @param player the player.
* @param node the node.
* @param armour the armour.
* @param amount the amount.
*/
public StudArmourPulse(Player player, Item node, final StuddedArmour armour, final int amount) {
super(player, node);
this.armour = armour;
this.amount = amount;
}
@Override
public boolean checkRequirements() {
if (player.getSkills().getLevel(Skills.CRAFTING) < armour.getLevel()) {
player.getPacketDispatch().sendMessage("You need a Crafting level of at least " + armour.getLevel() + " to do this.");
return false;
}
if (!player.getInventory().containsItem(STEEL_STUDS)) {
player.getPacketDispatch().sendMessage("You need studs in order to make studded armour.");
return false;
}
if (!player.getInventory().containsItem(armour.getItem())) {
return false;
}
return true;
}
@Override
public void animate() {
if (ticks % 5 == 0) {
player.animate(ANIMATION);
}
}
@Override
public boolean reward() {
if (++ticks % 5 != 0) {
return false;
}
if (player.getInventory().remove(armour.getItem(), STEEL_STUDS)) {
player.getInventory().add(armour.getStudded());
player.getSkills().addExperience(Skills.CRAFTING, armour.getExperience(), true);
player.getPacketDispatch().sendMessage("You make a " + armour.getStudded().getName().toLowerCase() + ".");
}
amount--;
return amount < 1;
}
@Override
public void message(int type) {
switch (type) {
case 0:
player.getPacketDispatch().sendMessage("You use the studs with the " + node.getName().toLowerCase() + ".");
break;
}
}
}
}

View file

@ -0,0 +1,192 @@
package plugin.skill.crafting;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.SkillPulse;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.tools.StringUtils;
/**
* Represents the plugin used for weaving.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class WeaveOptionPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.setOptionHandler("weave", this);
return this;
}
@Override
public boolean handle(final Player player, final Node node, String option) {
new SkillDialogueHandler(player, SkillDialogue.THREE_OPTION, WeavingItem.SACK.getProduct(), WeavingItem.BASKET.getProduct(), WeavingItem.CLOTH.getProduct()) {
@Override
public void create(int amount, int index) {
player.getPulseManager().run(new WeavePulse(player, (GameObject) node, WeavingItem.values()[index], amount));
}
}.open();
return true;
}
/**
* Represents the weaving pulse.
* @author 'Vexia
* @version 1.0
*/
public static final class WeavePulse extends SkillPulse<GameObject> {
/**
* Represents the animation to use.
*/
private static final Animation ANIMATION = new Animation(2270);
/**
* Represents the weaving item.
*/
private final WeavingItem type;
/**
* Represents the amount.
*/
private int amount;
/**
* Represents the ticks passed.
*/
private int ticks;
/**
* Constructs a new {@code WeavePulse} {@code Object}.
* @param player the player.
* @param node the node.
* @param amount the amount.
*/
public WeavePulse(Player player, GameObject node, final WeavingItem type, final int amount) {
super(player, node);
this.type = type;
this.amount = amount;
}
@Override
public boolean checkRequirements() {
if (player.getSkills().getLevel(Skills.CRAFTING) < type.getLevel()) {
player.getPacketDispatch().sendMessage("You need a Crafting level of at least " + type.getLevel() + " in order to do this.");
return false;
}
if (!player.getInventory().containsItem(type.getRequired())) {
player.getPacketDispatch().sendMessage("You need " + type.getRequired().getAmount() + " " + type.getRequired().getName().toLowerCase().replace("ball", "balls") + "" + (type == WeavingItem.SACK ? "s" : type == WeavingItem.CLOTH ? "" : "es") + " to weave " + (StringUtils.isPlusN(type.getProduct().getName().toLowerCase()) ? "an" : "a") + " " + type.getProduct().getName().toLowerCase() + ".");
return false;
}
return true;
}
@Override
public void animate() {
if (ticks % 5 == 0) {
player.animate(ANIMATION);
}
}
@Override
public boolean reward() {
if (++ticks % 5 != 0) {
return false;
}
if (player.getInventory().remove(type.getRequired())) {
player.getInventory().add(type.getProduct());
player.getSkills().addExperience(Skills.CRAFTING, type.getExperience(), true);
player.getPacketDispatch().sendMessage("You weave the " + type.getRequired().getName().toLowerCase().replace("ball", "balls") + "" + (type == WeavingItem.SACK ? "s" : type == WeavingItem.CLOTH ? "" : "es") + " into " + (StringUtils.isPlusN(type.getProduct().getName().toLowerCase()) ? "an" : "a") + " " + type.getProduct().getName().toLowerCase() + ".");
}
amount--;
return amount < 1;
}
}
/**
* Represents a weaving item.
* @author 'Vexia
* @version 1.0
*/
public enum WeavingItem {
SACK(new Item(5418), new Item(5931, 4), 21, 38), BASKET(new Item(5376), new Item(5933, 6), 36, 56), CLOTH(new Item(3224), new Item(1759, 4), 10, 12);
/**
* Represents the product.
*/
private final Item product;
/**
* Represents the required required.
*/
private final Item required;
/**
* Represents the level needed.
*/
private final int level;
/**
* Represents the experience gained.
*/
private final double experience;
/**
* Constructs a new {@code WeavingItem} {@code Object}.
* @param product the product.
* @param level the level.
* @param required the required.
* @param experience the experience.
*/
private WeavingItem(Item product, final Item required, int level, double experience) {
this.product = product;
this.required = required;
this.level = level;
this.experience = experience;
}
/**
* Gets the product.
* @return The product.
*/
public Item getProduct() {
return product;
}
/**
* Gets the required.
* @return The required
*/
public Item getRequired() {
return required;
}
/**
* Gets the level.
* @return The level.
*/
public int getLevel() {
return level;
}
/**
* Gets the experience.
* @return The experience.
*/
public double getExperience() {
return experience;
}
}
}

View file

@ -0,0 +1,244 @@
package plugin.skill.farming;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.content.skill.member.farming.FarmingItemHolder;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.tools.StringUtils;
/**
* Represents the plugin used to handle the managing of sacks and baskets.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class FarmHolderPlugin implements Plugin<Object> {
/**
* Represents the empty sack item.
*/
private static final Item SACK = new Item(5418);
/**
* Represents the empty basket item.
*/
private static final Item BASKET = new Item(5376);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
new ItemHolderPlugin().newInstance(arg);
new HaySackPlugin().newInstance(arg);
return this;
}
@Override
public Object fireEvent(String identifier, Object... args) {
return true;
}
/**
* Represents the plugin used to fill an empty sack with hay.
* @author 'Vexia
* @version 1.0
*/
public static final class HaySackPlugin extends UseWithHandler {
/**
* Represents the hay bale items.
*/
private static final int[] BALES = new int[] { 304, 8713, 8715, 36892, 36893 };
/**
* Represents the hay sack item.
*/
private static final Item HAY_SACK = new Item(6057);
/**
* Constructs a new {@code HaySackPlugin} {@code Object}.
*/
public HaySackPlugin() {
super(SACK.getId());
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int id : BALES) {
addHandler(id, OBJECT_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
if (player.getInventory().remove(event.getUsedItem())) {
player.getInventory().add(HAY_SACK);
player.getPacketDispatch().sendMessage("You fill the sack with straw.");
}
return true;
}
}
/**
* Represents the plugin used to handle the item holders.
* @author 'Vexia
* @version 1.0
*/
public static final class ItemHolderPlugin extends OptionHandler {
/**
* Represents the options to use.
*/
private static final String[] OPTIONS = new String[] { "fill", "empty", "remove-one" };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i = 0; i < 2; i++) {
ItemDefinition.forId(SACK.getId()).getConfigurations().put("option:" + OPTIONS[i], this);
ItemDefinition.forId(BASKET.getId()).getConfigurations().put("option:" + OPTIONS[i], this);
}
for (FarmingItemHolder holder : FarmingItemHolder.values()) {
for (Item item : holder.getHolders()) {
for (String option : OPTIONS) {
ItemDefinition.forId(item.getId()).getConfigurations().put("option:" + option, this);
}
}
}
new ItemHolderHandler().newInstance(arg);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final Item item = (Item) node;
final FarmingItemHolder holder = FarmingItemHolder.forHolder(item);
switch (option) {
case "fill":
final boolean sack = holder != null && holder.ordinal() < 3 ? true : (item.getId() == SACK.getId() ? true : false);
final Item base = getRemoveItem(player, item, sack);
if (base == null) {
player.getPacketDispatch().sendMessage(sack ? "You don't have any potatoes, onions, or cabbages." : "You don't have any fruit to fill the basket with.");
return true;
}
final Item remove = new Item(base.getId(), player.getInventory().getAmount(base));
final int defaultMax = (sack ? 10 : 5);
if (holder == null) {
fill(player, item, remove, FarmingItemHolder.forItem(remove), defaultMax);
return true;
}
if (holder.getAmount(item) == defaultMax) {
player.getPacketDispatch().sendMessage("The " + (sack ? "sack" : "fruit basket") + " is full.");
return true;
}
if (holder.getItem().getId() != base.getId()) {
player.sendMessage("You can't put " + base.getName().toLowerCase() + "s in there. You've already got " + holder.getItem().getName().toLowerCase() + "s in the sack.");
return true;
}
final int initialAmount = holder.getAmount(item);
fill(player, item, remove, holder, defaultMax - initialAmount);
break;
case "empty":
case "remove-one":
remove(player, item, holder, option.equals("empty") ? holder.getAmount(item) : 1);
break;
}
return true;
}
/**
* Method used to fill a basket or sack.
* @param player the player.
* @param item the item.
* @param remove the remove.
* @param holder the holder.
* @param max the max.
*/
private void fill(final Player player, final Item item, final Item remove, final FarmingItemHolder holder, final int max) {
if (remove.getAmount() > max) {
remove.setAmount(max);
}
if (player.getInventory().remove(remove)) {
final int old = item.getId() == BASKET.getId() || item.getId() == SACK.getId() ? 0 : holder.getAmount(item);
player.getInventory().replace(holder.getItem(old + remove.getAmount()), item.getSlot());
}
}
/**
* Method used to remove an item.
* @param player the player.
* @param item the item.
* @param holder the holder.
* @param amount the amount.
*/
private void remove(final Player player, final Item item, final FarmingItemHolder holder, final int amount) {
final Item remove = new Item(holder.getItem().getId(), amount);
if (!player.getInventory().hasSpaceFor(remove)) {
player.getPacketDispatch().sendMessage("You don't have enough inventory space.");
return;
}
if (player.getInventory().add(remove)) {
player.getInventory().replace(holder.getItem(holder.getAmount(item) - remove.getAmount()), item.getSlot());
player.getPacketDispatch().sendMessage("You take " + (remove.getAmount() < 2 ? (StringUtils.isPlusN(remove.getName().toLowerCase()) ? "an" : "a") : "" + remove.getAmount()) + " " + remove.getName().toLowerCase() + (remove.getAmount() > 1 ? "s" : "") + " out of the " + (holder.ordinal() < 3 ? "sack" : "basket") + ".");
}
}
/**
* Gets the item to remove from the inventory.
* @param player the player.
* @param item the item.
* @param sack if a sack.
* @return {@code Item} or {@code Null}.
*/
private Item getRemoveItem(final Player player, final Item item, final boolean sack) {
final int start = sack ? 0 : 3;
final int end = sack ? 3 : FarmingItemHolder.values().length;
for (int i = start; i < end; i++) {
if (player.getInventory().containsItem(FarmingItemHolder.values()[i].getItem())) {
return FarmingItemHolder.values()[i].getItem();
}
}
return null;
}
@Override
public boolean isWalk() {
return false;
}
/**
* Represents the use with handler for sacks & baskets.
* @author 'Vexia
* @version 1.0
*/
public final class ItemHolderHandler extends UseWithHandler {
/**
* Constructs a new {@code ItemHolderHandler} {@code Object}.
*/
public ItemHolderHandler() {
super(BASKET.getId(), SACK.getId(), 5460, 5462, 5464, 5466, 5468, 5470, 5472, 5474, 5476, 5478, 5440, 5442, 5444, 5446, 5448, 5450, 5452, 5454, 5456, 5458, 5420, 5422, 5424, 5426, 5428, 5430, 5432, 5434, 5436, 5438, 5378, 5380, 5382, 5384, 5386, 5408, 5410, 5412, 5414, 5416, 5388, 5390, 5392, 5394, 5396, 5398, 5400, 5402, 5404, 5406, 5960, 5962, 5964, 5966, 5968);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (FarmingItemHolder holder : FarmingItemHolder.values()) {
addHandler(holder.getItem().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
return false;
}
}
}
}

View file

@ -0,0 +1,718 @@
package plugin.skill.farming;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.content.skill.member.farming.FarmingConstant;
import org.crandor.game.content.skill.member.farming.FarmingNode;
import org.crandor.game.content.skill.member.farming.FarmingPatch;
import org.crandor.game.content.skill.member.farming.pot.Saplings;
import org.crandor.game.content.skill.member.farming.tool.PatchTool;
import org.crandor.game.content.skill.member.farming.wrapper.PatchWrapper;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
import org.crandor.tools.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Represents the option plugin used to handle farming interactions.
* @author 'Vexia
* @versio 1.0
*/
@InitializablePlugin
public final class FarmingPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.setOptionHandler("inspect", this);
ObjectDefinition.setOptionHandler("guide", this);
ObjectDefinition.setOptionHandler("harvest", this);
ObjectDefinition.setOptionHandler("check-health", this);
addPickingObject(FarmingPatch.FLOWER, this);
addPickingObject(FarmingPatch.HERB, this);
addPickingObject(FarmingPatch.BUSHES, this);
addPickingObject(FarmingPatch.FRUIT_TREE, this);
addPickingObject(FarmingPatch.EVIL_TURNIP, this);
addPickingObject(FarmingPatch.CACTUS, this);
addPickingObject(FarmingPatch.BELLADONNA, this);
addPickingObject(FarmingPatch.CALQUAT, this);
PluginManager.definePlugin(new OptionHandler() {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(6032).getConfigurations().put("option:empty", this);
ItemDefinition.forId(6034).getConfigurations().put("option:empty", this);
ItemDefinition.forId(6036).getConfigurations().put("option:empty", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
if (node.getId() == 6036) {
player.getInventory().replace(new Item(229), ((Item) node).getSlot());
return true;
}
player.getInventory().replace(new Item(1925), ((Item) node).getSlot());
return true;
}
@Override
public boolean isWalk() {
return false;
}
});
new FarmingEquipmentStore().newInstance(arg);
new CompostPlugin().newInstance(arg);
new FarmToolPlugin().newInstance(arg);
new PlantSeedPlugin().newInstance(arg);
new ScarecrowPlugin().newInstance(arg);
new PotSaplingPlugin().newInstance(arg);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final GameObject object = (GameObject) node;
final PatchWrapper wrapper = player.getFarmingManager().getPatchWrapper(object.getWrapper().getId());
if (wrapper == null) {
return false;
}
switch (option) {
case "inspect":
wrapper.getInteractor().inspect();
break;
case "guide":
wrapper.getInteractor().openGuide();
break;
case "harvest":
wrapper.getInteractor().harvest();
break;
case "pick":
case "pick-from":
case "pick-spine":
case "pick-apple":
case "pick-banana":
case "pick-orange":
case "pick-curry":
case "pick-pineapple":
case "pick-papaya":
case "pick-coconut":
case "pick-leaf":
case "pick-fruit":
wrapper.getInteractor().pick();
break;
case "check-health":
wrapper.getInteractor().checkHealth();
break;
}
return true;
}
/**
* Method used to add a picking object.
* @param patch the patch.
* @param handler the handler.
*/
public static void addPickingObject(final FarmingPatch patch, final OptionHandler handler) {
String[] fruits = new String[] { "apple", "banana", "orange", "curry", "pineapple", "papaya", "coconut", "leaf", "fruit" };
for (int ids : patch.getWrapperIds()) {
int[] children = handler.getValidChildren(ids);
for (int id : children) {
ObjectDefinition.forId(id).getConfigurations().put("option:pick", handler);
ObjectDefinition.forId(id).getConfigurations().put("option:pick-from", handler);
ObjectDefinition.forId(id).getConfigurations().put("option:pick-spine", handler);
ObjectDefinition.forId(id).getConfigurations().put("option:pick-fruit", handler);
if (patch == FarmingPatch.FRUIT_TREE) {
for (String s : fruits) {
ObjectDefinition.forId(id).getConfigurations().put("option:pick-" + s, handler);
}
}
}
}
}
/**
* Represents the planting of a seed plugin.
* @author 'Vexia
* @version 1.0
*/
public static final class PlantSeedPlugin extends UseWithHandler {
/**
* Constructs a new {@code PlantSeedPlugin} {@code Object}.
*/
public PlantSeedPlugin() {
super(getSeeds());
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (FarmingPatch patch : FarmingPatch.values()) {
for (int i : patch.getWrapperIds()) {
int[] childs = getValidChildren(i);
for (int child : childs) {
addHandler(child, OBJECT_TYPE, this);
}
}
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final PatchWrapper wrapper = player.getFarmingManager().getPatchWrapper(((GameObject) event.getUsedWith()).getWrapper().getId());
if (wrapper != null && player != null && event.getUsedItem() != null) {// Splinter
wrapper.getInteractor().plant(event.getUsedItem());
}
return true;
}
/**
* Gets the seeds.
* @return the seeds.
*/
private static int[] getSeeds() {
List<Integer> ids = new ArrayList<>();
for (FarmingPatch patch : FarmingPatch.values()) {
for (FarmingNode node : patch.getNodes()) {
ids.add(node.getSeed().getId());
}
}
int[] array = new int[ids.size()];
for (int i = 0; i < ids.size(); i++) {
array[i] = ids.get(i);
}
return array;
}
}
/**
* Represents the plugin used to handle a farm tool interaction with a
* patch.
* @author 'Vexia
* @version 1.0
*/
public static final class FarmToolPlugin extends UseWithHandler {
/**
* Constructs a new {@code FarmToolPlugin} {@code Object}.
*/
public FarmToolPlugin() {
super(getTools());
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (FarmingPatch patch : FarmingPatch.values()) {
for (int i : patch.getWrapperIds()) {
int[] childs = getValidChildren(i);
for (int child : childs) {
addHandler(child, OBJECT_TYPE, this);
}
}
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final PatchWrapper wrapper = player.getFarmingManager().getPatchWrapper(((GameObject) event.getUsedWith()).getWrapper().getId());
wrapper.getInteractor().handleToolInteraction(event.getUsedItem(), "force");
return true;
}
/**
* Gets the tools.
* @return the tools.
*/
private static int[] getTools() {
List<Integer> ids = new ArrayList<>();
ids.add(6032);// compost
ids.add(6034);// super compost
for (PatchTool tool : PatchTool.values()) {
for (Item i : tool.getTools()) {
ids.add(i.getId());
}
}
int[] tools = new int[ids.size()];
for (int i = 0; i < tools.length; i++) {
tools[i] = ids.get(i);
}
return tools;
}
}
/**
* Represents the plugin used to interact with compost.
* @author 'Vexia
* @version 1.0
*/
public static final class CompostPlugin extends UseWithHandler {
/**
* Represents the compost object wrapper ids.
*/
private static final int[] WRAPPER_IDS = new int[] { 7836, 7837, 7838, 7839 };
/**
* Constructs a new {@code CompostPlugin} {@code Object}.
*/
public CompostPlugin() {
super(FarmingConstant.getFarmingProducts());
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i : WRAPPER_IDS) {
int[] childs = getValidChildren(i);
for (int child : childs) {
addHandler(child, OBJECT_TYPE, this);
}
}
new CompostOptionPlugin().newInstance(arg);
new CompostBucketPlugin().newInstance(arg);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
player.getFarmingManager().getCompostManager().fill(player, event.getUsedItem(), (GameObject) event.getUsedWith(), "bin", 1);
return true;
}
/**
* Represents the compost bucket plugin use with handler.
* @author 'Vexia
* @version 1.0
*/
public static final class CompostBucketPlugin extends UseWithHandler {
/**
* Represents the ids to use.
*/
private static final int[] IDS = new int[] { 7814, 7815, 7816, 7817, 7824, 7825, 7826, 7827 };
/**
* Constructs a new {@code CompostBucketPlugin} {@code Object}.
*/
public CompostBucketPlugin() {
super(1925);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i : IDS) {
addHandler(i, OBJECT_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
player.getFarmingManager().getCompostManager().fill(player, event.getUsedItem(), (GameObject) event.getUsedWith(), "bucket", 1);
return true;
}
}
/**
* Represents the compost option plugin.
* @author 'Vexia
* @version 1.0
*/
public static final class CompostOptionPlugin extends OptionHandler {
/**
* Represents the ids to use.
*/
private static final int[] IDS = new int[] { 7810, 7812, 7813, 7820, 7822, 7823, 7829, 7830, 7831, 7833, 7834, 7835 };
/**
* Represents the options to use.
*/
private static final String[] OPTIONS = new String[] { "close", "open", "take-tomato" };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i : IDS) {
for (String option : OPTIONS) {
ObjectDefinition.forId(i).getConfigurations().put("option:" + option, this);
}
}
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (option) {
case "close":
player.getFarmingManager().getCompostManager().getBin((GameObject) node).close(player);
break;
case "open":
player.getFarmingManager().getCompostManager().getBin((GameObject) node).open(player);
break;
case "take-tomato":
player.getFarmingManager().getCompostManager().getBin((GameObject) node).takeTomato(player);
break;
}
return true;
}
}
}
/**
* Represents the component plugin used for the farming store.
* @author 'Vexia
* @version 1.0
*/
public final class FarmingEquipmentStore extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(125, this);
ComponentDefinition.put(126, this);
return this;
}
@Override
public boolean handle(final Player player, Component component, int opcode, int button, final int slot, int itemId) {
switch (component.getId()) {
case 125:
if (opcode == 155) {
switch (button) {
case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
case 39:
case 40:
case 41:
player.getFarmingManager().getEquipment().remove(player, button - 33, 1);
break;
}
break;
} else if (opcode != 155) {
switch (button) {
case 39:
case 40:
case 41:
switch(opcode){
case 196:
player.getFarmingManager().getEquipment().remove(player, 7 + slot, 5);
break;
case 124:
player.getFarmingManager().getEquipment().remove(player, 7 + slot, 28);
break;
case 199:
final int amount = getAmount(player, slot + 7, opcode);
if (amount == -1) {
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
player.getFarmingManager().getEquipment().remove(player, 7 + slot, (int) getValue());
return true;
}
});
player.getDialogueInterpreter().sendInput(false,"Enter amount:");
return true;
}
player.getFarmingManager().getEquipment().remove(player, 6 + slot, amount);
break;
}
}
}
break;
case 126:
if(opcode == 155){
switch(button){
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
player.getFarmingManager().getEquipment().store(player, button - 18, 1);
break;
}
} else if (opcode != 155){
switch (opcode) {
case 196:
player.getFarmingManager().getEquipment().store(player, 7 + slot, 5);
break;
case 124:
player.getFarmingManager().getEquipment().store(player, 7 + slot, 28);
break;
case 199:
final int amount = getAmount(player, slot + 6, opcode);
if (amount == -1) {
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
player.getFarmingManager().getEquipment().store(player, 7 + slot, (int) getValue());
return true;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter amount:");
return true;
}
player.getFarmingManager().getEquipment().store(player, 6 + slot, amount);
break;
}
}
break;
}
return true;
}
/**
* Gets the amount to store/remove.
* @param player the player.
* @param slot the slot.
* @param opcode the opcode.
* @return the amount.
*/
private int getAmount(final Player player, int slot, int opcode) {
return opcode == 133 ? 1 : opcode == 236 ? 5 : opcode == 157 ? player.getFarmingManager().getEquipment().getInventoryAmount(player, slot) : -1;
}
}
/**
* Represents the plugin used to make a scarecrow.
* @author 'Vexia
* @version 1.0
*/
public static final class ScarecrowPlugin extends UseWithHandler {
/**
* Constructs a new {@code ScarecrowPlugin} {@code Object}.
*/
public ScarecrowPlugin() {
super(6059);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int flower : FarmingPatch.FLOWER.getWrapperIds()) {
int[] children = getValidChildren(flower);
for (int id : children) {
addHandler(id, OBJECT_TYPE, this);
}
}
new ScarecrowBuildHandler().newInstance(arg);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final PatchWrapper wrapper = player.getFarmingManager().getPatchWrapper(((GameObject) event.getUsedWith()).getWrapper().getId());
wrapper.getInteractor().addScarecrow();
return true;
}
/**
* Represents the class used to build the scarecrow.
* @author 'Vexia
* @version 1.0
*/
public static final class ScarecrowBuildHandler extends UseWithHandler {
/**
* Represents the scarecrow item.
*/
private static final Item SCARECROW = new Item(6059);
/**
* Represents the hay sack item.
*/
private static final Item HAY_SACK = new Item(6057);
/**
* Represents the bronze spear item.
*/
private static final Item BRONZE_SPEAR = new Item(1237);
/**
* Represents the watermelon item.
*/
private static final Item WATERMELON = new Item(5982);
/**
* Constructs a new {@code ScarecrowBuildHandler} {@code Object}.
*/
public ScarecrowBuildHandler() {
super(HAY_SACK.getId(), 6058);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(WATERMELON.getId(), ITEM_TYPE, this);
addHandler(BRONZE_SPEAR.getId(), ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final Item first = event.getUsedItem();
final Item second = (Item) event.getUsedWith();
if (player.getSkills().getLevel(Skills.FARMING) < 23) {
player.getPacketDispatch().sendMessage("You need a Farming level of at least 23 to do this.");
return true;
}
if (first.getId() == HAY_SACK.getId() && second.getId() == BRONZE_SPEAR.getId()) {
if (player.getInventory().remove(first, second)) {
player.getInventory().add(new Item(6058));
player.getPacketDispatch().sendMessage("You stick the bronze spear through the sack.");
return true;
}
} else if (first.getId() == 6058 && second.getId() == WATERMELON.getId()) {
if (player.getInventory().remove(first, second)) {
player.getInventory().add(SCARECROW);
player.getSkills().addExperience(Skills.FARMING, 25, true);
player.getPacketDispatch().sendMessage("You stick a watermelon on top of the hay sack.");
return true;
}
}
return false;
}
}
}
/**
* Represents the plugin used to make a sapling.
* @author 'Vexia
* @version 1.0
*/
public static final class PotSaplingPlugin extends UseWithHandler {
/**
* Constructs a new {@code PotSaplingPlugin} {@code Object}.
*/
public PotSaplingPlugin() {
super(5354);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Saplings sap : Saplings.values()) {
addHandler(sap.getSeed().getId(), ITEM_TYPE, this);
}
new PotWateringPlugin().newInstance(arg);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Saplings sapling = Saplings.forSeed((Item) event.getUsedWith());
final Player player = event.getPlayer();
if (player.getSkills().getLevel(Skills.FARMING) < sapling.getLevel()) {
player.getPacketDispatch().sendMessage("You need a Farming level of at least " + sapling.getLevel() + " to do that.");
return true;
}
if (player.getInventory().remove(sapling.getSeed(), event.getUsedItem())) {
player.getInventory().add(sapling.getSeedling());
player.getPacketDispatch().sendMessage("You sow " + (StringUtils.isPlusN(sapling.getSeed().getName()) ? "an" : "a") + " " + sapling.getSeed().getName().toLowerCase() + " in the plantpot.");
player.getPacketDispatch().sendMessage("It needs watering before it will grow.");
}
return true;
}
/**
* Represents the plugin used to water a plant pot.
* @author 'Vexia
* @version 1.0
*/
public final static class PotWateringPlugin extends UseWithHandler {
/**
* Constructs a new {@code PotWateringPlugin} {@code Object}.
*/
public PotWateringPlugin() {
super(getWateringCans());
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Saplings sap : Saplings.values()) {
addHandler(sap.getSeedling().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final Item can = event.getUsedItem().getName().contains("can") ? event.getUsedItem() : (Item) event.getUsedWith();
final Item seedling = event.getUsedItem().getName().contains("seedling") ? event.getUsedItem() : (Item) event.getUsedWith();
final Saplings sapling = Saplings.forSeedling(seedling);
if (can.getId() == 5331) {
return false;
}
if (seedling.getCharge() > 1000) {
player.getPacketDispatch().sendMessage("The seedling has already been watered.");
return true;
}
player.getFarmingManager().getSeedlingManager().addSeedling(seedling);
Item newCan = getNextCan(can);
if (newCan != null) {
player.getInventory().replace(newCan, can.getSlot());
}
player.getPacketDispatch().sendMessage("You water the " + sapling.getSeed().getName().toLowerCase() + ".");
return true;
}
/**
* Gets the watering cans.
* @return the cans.
*/
private static final int[] getWateringCans() {
int[] cans = new int[PatchTool.WATERING_CAN.getTools().length];
for (int i = 0; i < PatchTool.WATERING_CAN.getTools().length; i++) {
cans[i] = PatchTool.WATERING_CAN.getTools()[i].getId();
}
return cans;
}
/**
* Gets the next can item.
* @return the next can.
*/
private Item getNextCan(Item tool) {
Item can = null;
for (int i = 0; i < PatchTool.WATERING_CAN.getTools().length; i++) {
if (PatchTool.WATERING_CAN.getTools()[i].getId() == tool.getId()) {
return PatchTool.WATERING_CAN.getTools()[(i + 1)];
}
}
return can;
}
}
}
}

View file

@ -0,0 +1,616 @@
package plugin.skill.farming;
import org.crandor.cache.def.impl.NPCDefinition;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.skill.member.farming.FarmingItemHolder;
import org.crandor.game.content.skill.member.farming.FarmingPatch;
import org.crandor.game.content.skill.member.farming.wrapper.PatchWrapper;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.tools.StringUtils;
/**
* Represents the plguin used for the crop watcher.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class GardenerPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Gardener gardener : Gardener.values()) {
NPCDefinition.forId(gardener.getNpc()).getConfigurations().put("option:pay", this);
NPCDefinition.forId(gardener.getNpc()).getConfigurations().put("option:pay (north)", this);
NPCDefinition.forId(gardener.getNpc()).getConfigurations().put("option:pay (south)", this);
NPCDefinition.forId(gardener.getNpc()).getConfigurations().put("option:pay (north-west)", this);
NPCDefinition.forId(gardener.getNpc()).getConfigurations().put("option:pay (south-east)", this);
}
new GardenerDialogue().init();
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final NPC npc = (NPC) node;
player.getDialogueInterpreter().open(npc.getId(), npc, option);
return true;
}
/**
* Represents the dialogue plugin used for the crop watcher.
* @author 'Vexia
* @version 1.0
*/
public static final class GardenerDialogue extends DialoguePlugin {
/**
* Represents the items needed to removr a tree.
*/
private static final Item TREE_COINS = new Item(995, 200);
/**
* Represents the gardener.
*/
private Gardener gardener;
/**
* Represents the object.
*/
private GameObject object;
/**
* Represents the wrapper being used.
*/
private PatchWrapper wrapper;
/**
* Represents the pay option.
*/
private String option;
/**
* Constructs a new {@code CropwatcherDialogue} {@code Object}.
* @param player the player.
*/
public GardenerDialogue(final Player player) {
super(player);
}
/**
* Constructs a new {@code CropwatcherDialogue} {@code Object}.
*/
public GardenerDialogue() {
/**
* empty.
*/
}
@Override
public DialoguePlugin newInstance(Player player) {
return new GardenerDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
if (args.length > 1) {
option = (String) args[1];
if (!setData()) {
end();
player.sendMessage("Error occured! Report to admin.");
return true;
}
if (!canProtect()) {
return true;
}
if (!hasItem()) {
npc("I want " + getItemName() + " for that.");
stage = 11;
} else {
interpreter.sendOptions("Pay " + getItemName() + "?", "Yes", "No");
stage = 15;
}
return true;
}
options("Would you look after my crops for me?", "Can you give me any farming advice?", "Can you sell me something?", "That's all thanks.");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 10:
gardener = Gardener.forId(npc.getId());
if (gardener.getLocations().length > 1) {
options(npc.getDefinition().getOptions()[2], npc.getDefinition().getOptions()[3]);
stage = 82;
return true;
}
if (!setData()) {
end();
player.sendMessage("Error occured! Report to admin.");
return true;
}
if (!canProtect()) {
return true;
}
if (!hasItem()) {
npc("If you like, but I want " + getItemName() + " for that.");
stage = 11;
} else {
options("Okay, it's a deal.", "No, that's too much.");
stage = 16;
}
break;
case 11:
player("I'm afraid I don't have enough of those at the moment.");
stage = 12;
break;
case 12:
npc("Well, I'm not wasting my time for free.");
stage = 34;
break;
case 13:
player("Thanks, maybe another time.");
stage = 34;
break;
case 15:
switch (buttonId) {
case 1:
pay();
break;
case 2:
end();
break;
}
break;
case 16:
switch (buttonId) {
case 1:
player("Okay, it's a deal.");
stage = 17;
break;
case 2:
player("No, that's too much.");
stage = 12;
break;
}
break;
case 17:
pay();
break;
case 18:
end();
break;
case 80:// remove tree.
switch (buttonId) {
case 1:
if (!player.getInventory().containsItem(TREE_COINS)) {
player("Sorry, I don't seem to have enough money.");
stage = 34;
return true;
}
end();
if (player.getInventory().remove(TREE_COINS)) {
interpreter.sendDialogue("The gardener obligingly removes your tree.");
wrapper.getCycle().clear(player);
return true;
}
break;
case 2:
player("No thanks.");
stage = 34;
break;
}
break;
case 82:// pay (south), etc
switch (buttonId) {
case 1:
option = npc.getDefinition().getOptions()[2];
break;
case 2:
option = npc.getDefinition().getOptions()[3];
break;
}
setData();
pay();
break;
case 0:
switch (buttonId) {
case 1:
player("Would you look after my crops for me?");
stage = 10;
break;
case 2:
player("Can you give me farming advice?");
stage = 20;
break;
case 3:
player("Can you sell me something?");
stage = 30;
break;
case 4:
player("That's all, thanks.");
stage = 40;
break;
}
break;
case 20:
npc("There's four main Farming areas - Elstan looks after", "an area south of Falador, Dantaera has one to the", "north of Catherby, Krage has one near Ardougne,", "and Lyra looks after a place in north Morytania.");
stage = 21;
break;
case 21:
options("Would you look after my crops for me?", "Can you give me any farming advice?", "Can you sell me something?", "That's all thanks.");
stage = 0;
break;
case 30:
npc("That depends on whether I have it to sell.", "What is it that you're looking for?");
stage = 31;
break;
case 31:
options("Some plant cure.", "A bucket of compost.", "A rake.", "(See more items)");
stage = 32;
break;
case 32:
switch (buttonId) {
case 1:
player("Some plant cure.");
purchase(ShopItem.PLANT_CURE);
break;
case 2:
player("A bucket of compost.");
purchase(ShopItem.COMPOST);
break;
case 3:
player("A rake.");
purchase(ShopItem.RAKE);
break;
case 4:
options("A watering can.", "A gardening trowel.", "A seed dibber.", "(See previous items)", "Forget it.");
stage = 33;
break;
}
break;
case 33:
switch (buttonId) {
case 1:
player("A watering can.");
purchase(ShopItem.WATERING_CAN);
break;
case 2:
player("A gardening trowel.");
purchase(ShopItem.GARDENING_TROWEL);
break;
case 3:
player("A seed dibber.");
purchase(ShopItem.SEED_DIBBER);
break;
case 4:
options("Some plant cure.", "A bucket of compost.", "A rake.", "(See more items)");
stage = 32;
break;
case 5:
player("Forget it, you don't have anything I need.");
stage = 34;
break;
}
break;
case 34:
end();
break;
case 35:
options("Yes, that sounds like a fair price.", "No thanks, I can get that much cheaper elsewhere.");
stage = 36;
break;
case 36:
switch (buttonId) {
case 1:
player("Yes, that sounds like a fair price.");
stage = 37;
break;
case 2:
player("No thanks, I can get that much cheaper elsewhere.");
stage = 34;
break;
}
break;
case 37:
final ShopItem item = player.getAttribute("farming:shop-item", ShopItem.PLANT_CURE);
if (item.purchase(player)) {
end();
} else {
stage = 40;
}
break;
case 40:
end();
break;
}
return true;
}
/**
* Sets the data.
*/
private boolean setData() {
if (npc == null || option == null) {
return false;
}
gardener = Gardener.forId(npc.getId());
if (gardener == null) {
return false;
}
object = RegionManager.getObject(gardener.getLocations()[option == null ? 0 : option.equals("pay") || option.contains("north") ? 0 : 1]);
if (object == null) {
return false;
}
wrapper = player.getFarmingManager().getPatchWrapper(object.getWrapper().getId());
return wrapper != null;
}
/**
* Method used to pay the gardener.
*/
private void pay() {
Item item = getItem();
if (item == null) {
return;
}
if (!canProtect() || !player.getInventory().containsItem(item)) {
return;
}
if (player.getInventory().remove(item)) {
wrapper.getCycle().setProtection(true);
npc("That'll do nicely, Sir. Leave it with me - I'll make sure it", "grows for you.");
stage = 18;
}
}
/**
* Gets the item name.
* @return the name.
*/
private String getItemName() {
final Item item = getItem();
if (item == null) {
return "report-me";
}
final int amount = item.getAmount();
final FarmingItemHolder holder = FarmingItemHolder.forHolder(item);
String name = item.getName().toLowerCase();
if (holder != null) {
if (holder.isBasket()) {
name = String.valueOf(amount) + " basket of " + holder.name().toLowerCase() + "s";
} else {
name = String.valueOf(amount) + " sack of " + holder.name().toLowerCase() + "s";
}
}
if (amount < 2) {
return name;
} else {
if (holder == null) {
return amount + " " + name + "s";
} else {
return name;
}
}
}
/**
* Checks if the player has the required item.
* @return {@code True} if so.
*/
private boolean hasItem() {
return getItem() != null && player.getInventory().containsItem(getItem());
}
/**
* Gets the item to use.
* @return the item.
*/
private Item getItem() {
if (wrapper == null || wrapper.getNode() == null || wrapper.getNode().getProtection() == null) {
return null;
}
final Item[] items = wrapper.getNode().getProtection();
if (items == null) {
return null;
}
if (items.length <= 0) {
return null;
}
return items[0];
}
/**
* Checks if the patch can be protected.
* @return {@code True} if so.
*/
private boolean canProtect() {
if (wrapper.getCycle().getDiseaseHandler().isDiseased() || wrapper.getCycle().getDeathHandler().isDead()) {
npc("You need to plant a healthy plant in that patch.");
stage = 34;
return false;
}
if (wrapper.getCycle().getGrowthHandler().isFullGrown() && (wrapper.getPatch() == FarmingPatch.TREE || wrapper.getPatch() == FarmingPatch.FRUIT_TREE)) {
interpreter.sendOptions("Pay 200 gp to remove the tree?", "Yes, get rid of the tree.", "No thanks.");
stage = 80;
return false;
}
if (wrapper.getCycle().isProtected()) {
npc("I'm already looking after that patch for you.");
stage = 34;
return false;
}
if (!wrapper.getCycle().getGrowthHandler().isGrowing() && !wrapper.getCycle().getWaterHandler().isWatered()) {
npc("You don't have anything planted in that patch. Plant", "something and I might agree to look after it for you.");
stage = 34;
return false;
}
if (wrapper.getNode().getProtection() == null) {
npc("Sorry, I can't watch over that plant.");
stage = 34;
return false;
}
return true;
}
/**
* Method used to attempt to buy an item.
* @param item the item.
*/
private void purchase(ShopItem item) {
player.setAttribute("farming:shop-item", item);
final String type = (item.equals(ShopItem.RAKE) || item.equals(ShopItem.WATERING_CAN) || item.equals(ShopItem.GARDENING_TROWEL) || item.equals(ShopItem.SEED_DIBBER) ? "one" : "some");
if (item == ShopItem.GARDENING_TROWEL || item == ShopItem.SEED_DIBBER) {
npc("A " + item.getItem().getName().toLowerCase() + ", eh? I might have one spare ... tell", "you what, I'll sell it to you for 15GP if you like.");
} else {
npc(StringUtils.formatDisplayName(item.getItem().getName()) + ", eh? I might have " + type + " of those.", "Tell you what, I'll sell you " + type + " " + item.getItem().getName().toLowerCase() + " for " + item.getPrice().getAmount() + "", "GP if you like.");
}
stage = 35;
}
@Override
public int[] getIds() {
final int[] ids = new int[Gardener.values().length];
for (int i = 0; i < ids.length; i++) {
ids[i] = Gardener.values()[i].getNpc();
}
return ids;
}
}
/**
* Represents a shop item that can be purchased.
* @author 'Vexia
* @version 1.0
*/
public enum ShopItem {
PLANT_CURE(new Item(6036), new Item(995, 25)), COMPOST(new Item(6032), new Item(995, 35)), RAKE(new Item(5341), new Item(995, 15)), WATERING_CAN(new Item(5331), new Item(995, 25)), GARDENING_TROWEL(new Item(5325), new Item(995, 15)), SEED_DIBBER(new Item(5343), new Item(995, 15));
/**
* Represents the item.
*/
private final Item item;
/**
* Represents the price.
*/
private final Item price;
/**
* Constructs a new {@code ShopItem} {@code Object}.
* @param item the item.
* @param price the price.
*/
ShopItem(final Item item, final Item price) {
this.item = item;
this.price = price;
}
/**
* Checks if the purchase was a success.
* @param player the player.
* @return {@code True} if so.
*/
public boolean purchase(final Player player) {
if (!player.getInventory().hasSpaceFor(item)) {
player.getDialogueInterpreter().sendDialogues(player, null, "Sorry, I don't seem to have enough inventory space.");
return false;
}
if (!player.getInventory().containsItem(price)) {
player.getDialogueInterpreter().sendDialogues(player, null, "Sorry, I don't seem to have enough coins with me", "at this time.");
return false;
}
return player.getInventory().remove(price) && player.getInventory().add(item);
}
/**
* Gets the item.
* @return The item.
*/
public Item getItem() {
return item;
}
/**
* Gets the price.
* @return The price.
*/
public Item getPrice() {
return price;
}
}
/**
* Represents a crop watcher npc.
* @author 'Vexia
* @version 1.0
*/
public enum Gardener {
ALAIN(2339, new Location(2935, 3437, 0)), TREZNOR(2341, new Location(3228, 3458, 0)), AMAETHWR(2860, new Location(2345, 3162, 0)), BOLONGO(2343, new Location(2475, 3445, 0)), DANTAERA(2324, new Location(2808, 3467, 0), new Location(2808, 3459, 0)), DREVEN(2335, new Location(3181, 3357, 0)), ELLENA(2331, new Location(2860, 3433, 0)), ELSTAN(2323, new Location(3051, 3308, 0), new Location(3058, 3308, 0)), GARTH(2330, new Location(2764, 3212, 0)), GILETH(2344, new Location(2489, 3179, 0)), FAYETH(2342, new Location(3192, 3230, 0)), FRANCIS(2327, new Location(3810, 3336, 0)), FRIZZY_SKERNIP(4560, new Location(3059, 3257, 0)), HESKEL(2340, new Location(3003, 3372, 0)), KRAGEN(2325, new Location(2665, 3378, 0), new Location(2667, 3371, 0)), LYRA(2326, new Location(3605, 3525, 0), new Location(3598, 3526, 0)), MY_ARM(4947, new Location(2826, 3694, 0)), PRAISTAN_EBOLA(4562, new Location(2801, 3202, 0)), PRISSY_SCILLA(1037, new Location(2435, 3414, 0)), ROHNEN(2334, new Location(2664, 3525, 0)), SELENA(2332, new Location(2575, 3106, 0)), TARIA(2336, new Location(2940, 3221, 0)), TORRELL(2338, new Location(2617, 3225, 0)), VASQUEN(2333, new Location(3227, 3315, 0));
/**
* Represents the npc id.
*/
private final int npc;
/**
* Represents the location of patches.
*/
private final Location[] locations;
/**
* Constructs a new {@code Gardener} {@code Object}.
* @param npc the npc.
* @param locations the locations.
*/
Gardener(int npc, final Location... locations) {
this.npc = npc;
this.locations = locations;
}
/**
* Gets the gardener for the id.
* @param id the id.
* @return the gardener.
*/
public static Gardener forId(final int id) {
for (Gardener gardener : values()) {
if (gardener.getNpc() == id) {
return gardener;
}
}
return null;
}
/**
* Gets the locations.
* @return The locations.
*/
public Location[] getLocations() {
return locations;
}
/**
* Gets the npc.
* @return The npc.
*/
public int getNpc() {
return npc;
}
}
}

View file

@ -0,0 +1,225 @@
package plugin.skill.farming;
import org.crandor.cache.def.impl.NPCDefinition;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.dialogue.FacialExpression;
import org.crandor.game.content.skill.member.farming.FarmingNode;
import org.crandor.game.content.skill.member.farming.FarmingPatch;
import org.crandor.game.content.skill.member.herblore.Herbs;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
/**
* Represents the option handler used for a tool leprachaun.
* @author 'Vexia
* @versio 1.0
*/
@InitializablePlugin
public final class ToolLeprachaunPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.forId(3021).getConfigurations().put("option:exchange", this);
NPCDefinition.forId(4965).getConfigurations().put("option:exchange", this);
NPCDefinition.forId(3021).getConfigurations().put("option:teleport", this);
NPCDefinition.forId(4965).getConfigurations().put("option:teleport", this);
new ToolLeprechaunDialogue().init();
new BankNotePlugin().newInstance(arg);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (option) {
case "exchange":
player.getFarmingManager().getEquipment().open(player);
break;
case "teleport":
player.getPacketDispatch().sendMessage("The Leprachaun is not offering teleportation services at the moment.");
// player.getTeleporter().send(Location.create(1638, 4709, 0),
// TeleportType.NORMAL, 3);
break;
}
return true;
}
/**
* Represents the plugin used to exchange farming products in bank notes.
* @author 'Vexia
* @version 1.0
*/
public static final class BankNotePlugin extends UseWithHandler {
/**
* Constructs a new {@code BankNotePlugin} {@code Object}.
*/
public BankNotePlugin() {
super(getProducts());
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(3021, NPC_TYPE, this);
addHandler(4965, NPC_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
FarmingNode node = null;
for (FarmingPatch patch : FarmingPatch.values()) {
for (FarmingNode n : patch.getNodes()) {
if (n.getProduct().getId() == event.getUsedItem().getId()) {
node = n;
break;
}
}
}
if (node == null || event.getUsedItem().getDefinition().getNoteId() == -1) {
event.getPlayer().getDialogueInterpreter().sendDialogues((NPC) event.getUsedWith(), null, "Nay, I can't turn that into a banknote.");
} else {
int amount = event.getPlayer().getInventory().getAmount(event.getUsedItem());
if (event.getPlayer().getInventory().remove(new Item(event.getUsedItem().getId(), amount))) {
event.getPlayer().getInventory().add(new Item(event.getUsedItem().getDefinition().getNoteId(), amount));
}
event.getPlayer().getDialogueInterpreter().sendItemMessage(event.getUsedItem(), "The leprechaun exchanges your items for banknotes.");
}
return true;
}
/**
* Gets the products.
* @return the ids.
*/
public static int[] getProducts() {
final List<Integer> ids = new ArrayList<>();
for (FarmingPatch patch : FarmingPatch.values()) {
for (FarmingNode node : patch.getNodes()) {
ids.add(node.getProduct().getId());
}
}
for (Herbs h : Herbs.values()) {
ids.add(h.getHerb().getId());
}
final int[] array = new int[ids.size()];
for (int i = 0; i < array.length; i++) {
array[i] = ids.get(i);
}
return array;
}
}
/**
* Represents the dialogue plugin used for the tool leprachaun.
* @author 'Vexia
* @version 1.0
*/
public final class ToolLeprechaunDialogue extends DialoguePlugin {
/**
* Constructs a new {@code ToolLeprechaunDialogue} {@code Object}.
*/
public ToolLeprechaunDialogue() {
/**
* empty.
*/
}
public ToolLeprechaunDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new ToolLeprechaunDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
npc(FacialExpression.OSRS_NORMAL, "Ah, 'tis a foine day to be sure! Were yez wantin' me to", "store yer tools, or maybe ye might be wantin' yer stuff", "back from me?");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
options("Yes please.", "What can you store?", "What do you do with the tools you're storing?", "No thanks, I'll keep hold of my stuff.");
stage = 1;
break;
case 1:
switch (buttonId) {
case 1:
player("Yes please.");
stage = 10;
break;
case 2:
player("What can you store?");
stage = 20;
break;
case 3:
player("What do you do with the tools you're storing?", "They can't possibly all fit in your pockets!");
stage = 30;
break;
case 4:
player("No thanks, I'll keep hold of my stuff.");
stage = 40;
break;
}
break;
case 10:
end();
player.getFarmingManager().getEquipment().open(player);
break;
case 20:
npc(FacialExpression.OSRS_NORMAL, "We'll hold onto yer rake, yer seed dibber, yer spade,", "yer secateurs, yer waterin' can and yer trowel - but", "mind it's not one of them fancy trowels only", "achaeologists use!");
stage = 21;
break;
case 21:
npc(FacialExpression.OSRS_NORMAL, "We'll take a few buckets off yer hands too, and even", "yer compost and yer supercompost. There's room in", "our shed for plenty of compost, so bring it on!");
stage = 22;
break;
case 22:
npc(FacialExpression.OSRS_NORMAL, "Also, if you hand me yer farming produce, I might be", "able to change it into banknotes.");
stage = 23;
break;
case 23:
end();
break;
case 30:
npc(FacialExpression.OSRS_NORMAL, "We leprechauns have a shed where we keep 'em. It's a", "magic shed, so ye can get yer items back from any of", "us leprechauns whenever ye want. Saves ye havin' to", "carry loads of stuff around the country!");
stage = 31;
break;
case 31:
end();
break;
case 40:
npc(FacialExpression.OSRS_NORMAL, "Ye must be dafter then ye look if ye likes luggin' yer", "tools everywhere ye goes!");
stage = 41;
break;
case 41:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 3021, 4965 };
}
}
}

View file

@ -0,0 +1,48 @@
package plugin.skill.firemaking;
import org.crandor.game.content.global.tutorial.TutorialSession;
import org.crandor.game.content.global.tutorial.TutorialStage;
import org.crandor.game.content.skill.free.firemaking.FireMakingPulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle the lighting of a fire.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class FireMakingOptionPlugin extends UseWithHandler {
/**
* Constructs a new {@code FireMakingOptionPlugin} {@code Object}.
*/
public FireMakingOptionPlugin() {
super(1511, 1521, 1513, 1515, 1517, 1519, 1521, 2862, 3438, 3440, 3442, 3444, 3446, 3448, 6211, 6213, 6332, 6333, 7404, 7405, 7406, 8934, 9067, 10328, 10329, 10808, 10810, 10812, 11035, 12581, 12583, 3125);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(590, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
Item item = event.getUsedItem();
if (item == null) {
return false;
}
Player player = event.getPlayer();
if (TutorialSession.getExtension(player).getStage() == 8) {
TutorialStage.load(player, 9, false);
}
player.getPulseManager().run(new FireMakingPulse(player, item, null));
return true;
}
}

View file

@ -0,0 +1,33 @@
package plugin.skill.firemaking;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.content.skill.free.firemaking.FireMakingPulse;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.GroundItem;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to light a log.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class LightLogPlugin extends OptionHandler {
@Override
public boolean handle(Player player, Node node, String option) {
player.getPulseManager().run(new FireMakingPulse(player, ((Item) node), ((GroundItem) node)));
return true;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.setOptionHandler("light", this);
return this;
}
}

View file

@ -0,0 +1,58 @@
package plugin.skill.fishing;
import org.crandor.cache.def.impl.NPCDefinition;
import org.crandor.game.content.skill.free.fishing.FishingOption;
import org.crandor.game.content.skill.free.fishing.FishingPulse;
import org.crandor.game.content.skill.free.fishing.FishingSpot;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to start fishing.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class FishingOptionPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.setOptionHandler("net", this);
NPCDefinition.setOptionHandler("bait", this);
NPCDefinition.setOptionHandler("lure", this);
NPCDefinition.setOptionHandler("cage", this);
NPCDefinition.setOptionHandler("harpoon", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
NPC npc = (NPC) node;
FishingSpot spot = FishingSpot.forId(npc.getId());
if (spot == null) {
return false;
}
FishingOption opt = null;
for (FishingOption o : spot.getOptions()) {
if (o.getName().equals(option)) {
opt = o;
break;
}
}
if (opt == null) {
return false;
}
player.getPulseManager().run(new FishingPulse(player, npc, opt));
return true;
}
@Override
public Location getDestination(Node node, Node n) {
return null;
}
}

View file

@ -0,0 +1,71 @@
package plugin.skill.fletching;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.member.fletching.items.arrow.ArrowHead;
import org.crandor.game.content.skill.member.fletching.items.arrow.ArrowHeadPulse;
import org.crandor.game.content.skill.member.fletching.items.arrow.HeadlessArrowPulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.net.packet.PacketRepository;
import org.crandor.net.packet.context.ChildPositionContext;
import org.crandor.net.packet.out.RepositionChild;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to create arrows.
* @author Vexia
*/
@InitializablePlugin
public class ArrowCreatePlugin extends UseWithHandler {
/**
* Represents the headless arrow item.
*/
private static final Item HEADLESS_ARROW = new Item(53);
/**
* Constructs a new {@code ArrowCreatePlugin} {@code Object}.
*/
public ArrowCreatePlugin() {
super(314, 53);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(52, ITEM_TYPE, this);
for (ArrowHead head : ArrowHead.values()) {
addHandler(head.getTips().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
final ArrowHead head = ArrowHead.forItem((event.getUsedItem().getName().contains("tip") || event.getUsedItem().getName().contains("head")) ? event.getUsedItem() : event.getUsedWith().asItem());
final Player player = event.getPlayer();
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, head == null ? HEADLESS_ARROW : head.getProduct()) {
@Override
public void create(final int amount, int index) {
if (head == null) {
player.getPulseManager().run(new HeadlessArrowPulse(player, event.getUsedItem(), amount));
} else{
player.getPulseManager().run(new ArrowHeadPulse(player, event.getUsedItem(), head, amount));
}
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(head == null ? HEADLESS_ARROW : head.getTips());
}
};
handler.open();
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 309, 2, 210, 10));
return true;
}
}

View file

@ -0,0 +1,58 @@
package plugin.skill.fletching;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.member.fletching.items.bolts.Bolt;
import org.crandor.game.content.skill.member.fletching.items.bolts.BoltPulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.net.packet.PacketRepository;
import org.crandor.net.packet.context.ChildPositionContext;
import org.crandor.net.packet.out.RepositionChild;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the bolt creating plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class BoltCreatePlugin extends UseWithHandler {
/**
* Constructs a new {@code BoltCreatePlugin} {@code Object}.
*/
public BoltCreatePlugin() {
super(314);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Bolt bolt : Bolt.values()) {
addHandler(bolt.getItem().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
final Player player = event.getPlayer();
final Bolt bolt = Bolt.forItem(event.getUsedItem());
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, bolt.getProduct()) {
@Override
public void create(final int amount, int index) {
player.getPulseManager().run(new BoltPulse(player, event.getUsedItem(), bolt, amount));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(event.getUsedItem());
}
};
handler.open();
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 309, 2, 210, 10));
return true;
}
}

View file

@ -0,0 +1,61 @@
package plugin.skill.fletching;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.member.fletching.items.gem.GemBolt;
import org.crandor.game.content.skill.member.fletching.items.gem.GemBoltPulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.net.packet.PacketRepository;
import org.crandor.net.packet.context.ChildPositionContext;
import org.crandor.net.packet.out.RepositionChild;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle gem bolt making.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public class BoltGemPlugin extends UseWithHandler {
/**
* Constructs a new {@code BoltGemPlugin} {@code Object}.
*/
public BoltGemPlugin() {
super(45, 46, 9187, 9188, 9189, 9190, 9191, 9192, 9193, 9194);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (GemBolt bolt : GemBolt.values()) {
addHandler(bolt.getBase().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
final Player player = event.getPlayer();
final GemBolt bolt = GemBolt.forItems(event.getUsedItem(), event.getUsedWith().asItem());
if (bolt == null) {
return true;
}
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, bolt.getProduct()) {
@Override
public void create(final int amount, int index) {
player.getPulseManager().run(new GemBoltPulse(player, event.getUsedItem(), bolt, amount));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(event.getUsedItem());
}
};
handler.open();
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 309, 2, 210, 10));
return true;
}
}

View file

@ -0,0 +1,43 @@
package plugin.skill.fletching;
import org.crandor.game.content.skill.member.fletching.items.darts.Dart;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import plugin.quest.touristrap.TouristTrap;
/**
* Represents the plugin used to create a dart.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class DartCreatePlugin extends UseWithHandler {
/**
* Constructs a new {@code DartCreatePlugin} {@code Object}.
*/
public DartCreatePlugin() {
super(314);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Dart dart : Dart.values()) {
addHandler(dart.getItem().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
if (event.getPlayer().getQuestRepository().getQuest(TouristTrap.NAME).getStage(event.getPlayer()) < 60) {
event.getPlayer().getPacketDispatch().sendMessage("You need to start Tourist Trap in order to do this.");
return true;
}
event.getPlayer().getDialogueInterpreter().open(328933, event.getUsedItem(), event.getBaseItem());
return true;
}
}

View file

@ -0,0 +1,67 @@
package plugin.skill.fletching;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.member.fletching.FletchItem;
import org.crandor.game.content.skill.member.fletching.FletchType;
import org.crandor.game.content.skill.member.fletching.FletchingPulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to open the fletching dialogue.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public class FletchingPlugin extends UseWithHandler {
/**
* Constructs a new {@code FletchingPlugin} {@code Object}.
*/
public FletchingPlugin() {
super(1511, 1521, 1519, 1517, 1515, 1513, 6332, 6333);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(946, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
final FletchType type = FletchType.forItem(event.getUsedItem());
if (type == null) {
return true;
}
final Player player = event.getPlayer();
final Item log = event.getUsedItem();
Object[] items = new Object[type.getItems().length];
for (int i = 0; i < items.length; i++) {
items[i] = type.getItems()[i].getProduct();
}
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.forLength(type.getItems().length), items) {
@Override
public void create(final int amount, int index) {
final FletchItem fletch = type.getItems()[index];
fletch.setType(type);
player.getPulseManager().run(new FletchingPulse(player, log, amount, fletch));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(log);
}
};
handler.open();
return true;
}
}

View file

@ -0,0 +1,53 @@
package plugin.skill.fletching;
import org.crandor.game.content.dialogue.SkillDialogueHandler;
import org.crandor.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import org.crandor.game.content.skill.member.fletching.items.gem.Gem;
import org.crandor.game.content.skill.member.fletching.items.gem.GemBoltCutPulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the gem bolt creating plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class GemBoltPlugin extends UseWithHandler {
/**
* Constructs a new {@code GemBoltPlugin} {@code Object}.
*/
public GemBoltPlugin() {
super(1609, 1611, 1613, 1607, 1605, 1603, 1601, 1615, 6573);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(1755, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
final Player player = event.getPlayer();
final Gem gem = Gem.forItem(event.getUsedItem().getId() == 1755 ? event.getBaseItem() : event.getUsedItem());
new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, gem.getGem()) {
@Override
public void create(final int amount, final int index) {
player.getPulseManager().run(new GemBoltCutPulse(player, event.getUsedItem(), gem, amount));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(gem.getGem());
}
}.open();
return true;
}
}

View file

@ -0,0 +1,53 @@
package plugin.skill.fletching;
import org.crandor.game.content.skill.member.fletching.items.crossbow.Limb;
import org.crandor.game.content.skill.member.fletching.items.crossbow.StringCross;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to make a crossbow.
* @author 'Vexia
*/
@InitializablePlugin
public class MakeCrossbowPlugin extends UseWithHandler {
/**
* Constructs a new {@code StringcrossbowPlugin} {@code Object}.
*/
public MakeCrossbowPlugin() {
super(9420, 9423, 9422, 9425, 9427, 9429, 9431, /** crossbow string */
9438);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Limb l : Limb.values()) {
addHandler(l.getStock().getId(), ITEM_TYPE, this);
}
for (StringCross c : StringCross.values()) {
addHandler(c.getItem().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
if (event.getUsedItem().getName().toLowerCase().equals("string") || event.getBaseItem().getName().toLowerCase().contains("string")) {
player.getDialogueInterpreter().open(92747, event.getUsedItem().getId() == 9438 ? event.getBaseItem() : event.getUsedItem());
return true;
}
final Limb limb = Limb.forItems(event.getUsedItem(), event.getBaseItem());
if (limb == null) {
player.getDialogueInterpreter().sendDialogue("That's not the correct limb to attach.");
return true;
}
player.getDialogueInterpreter().open(84923, event.getUsedItem(), event.getBaseItem());
return true;
}
}

View file

@ -0,0 +1,69 @@
package plugin.skill.fletching;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to make a mithril grapple.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class MithGrapplePlugin extends UseWithHandler {
/**
* Represents the rope grapple.
*/
private static final Item ROPE_GRAPPLE = new Item(9419);
/**
* Represents the mith grapple.
*/
private static final Item MITH_GRAPPLE = new Item(9418);
/**
* Represents the rope item.
*/
private static final Item ROPE = new Item(954);
/**
* Constructs a new {@code MithGrapplePlugin} {@code Object}.
*/
public MithGrapplePlugin() {
super(9416, 954);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(9142, ITEM_TYPE, this);
addHandler(9418, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final Item first = event.getUsedItem();
final Item second = event.getBaseItem();
if (first.getId() == 9418 && second.getId() != 954) {
return false;
} else if (first.getId() == 9418 && second.getId() == 954) {
if (player.getInventory().remove(ROPE) && player.getInventory().remove(MITH_GRAPPLE)) {
player.getInventory().add(ROPE_GRAPPLE);
}
return true;
}
if (player.getSkills().getLevel(Skills.FLETCHING) < 59) {
player.getDialogueInterpreter().sendDialogue("You need a fletching level of 59 in order to do that.");
return true;
}
player.getDialogueInterpreter().open(903213, first, second);
return true;
}
}

View file

@ -0,0 +1,39 @@
package plugin.skill.fletching;
import org.crandor.game.content.skill.member.fletching.items.bow.StringBow;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to string a bow.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class StringbowPlugin extends UseWithHandler {
/**
* Constructs a new {@code StringbowPlugin} {@code Object}.
*/
public StringbowPlugin() {
super(1777);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (StringBow bw : StringBow.values()) {
addHandler(bw.getItem().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
player.getDialogueInterpreter().open(9174399, event.getUsedItem().getId() == 1777 ? event.getBaseItem() : event.getUsedItem());
return true;
}
}

View file

@ -0,0 +1,34 @@
package plugin.skill.gather;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.skill.free.gather.GatheringSkillPulse;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the gathering skill option handler plugin.
* @author Emperor
* @version 1.0
*/
@InitializablePlugin
public final class GatheringSkillOptionPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.setOptionHandler("chop down", this);
ObjectDefinition.setOptionHandler("chop-down", this);
ObjectDefinition.setOptionHandler("mine", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.getPulseManager().run(new GatheringSkillPulse(player, (GameObject) node));
return true;
}
}

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