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,75 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.NPCDefinition;
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.npc.NPC;
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.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* The plugin used to handle bedabin interactions.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class BedabinPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(2700).getConfigurations().put("option:walk-through", this);
ObjectDefinition.forId(2672).getConfigurations().put("option:use", this);
NPCDefinition.forId(834).getConfigurations().put("option:talk-to", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final int id = node.getId();
switch (option) {
case "talk-to":
player.getDialogueInterpreter().open(node.getId(), node);
break;
case "walk-through":
switch (id) {
case 2700:
if (player.getLocation().getY() >= 3046) {
final GameObject door = RegionManager.getObject(new Location(3169, 3046, 0));
ObjectBuilder.replace(door, door.transform(2701), 2);
player.getWalkingQueue().reset();
player.getWalkingQueue().addPath(3169, 3045);
player.getPacketDispatch().sendMessage("You walk back out the tent.");
break;
}
player.getDialogueInterpreter().open(834, RegionManager.getNpc(player, 834));
break;
}
break;
case "use":
switch (id) {
case 2672:
player.getPacketDispatch().sendMessage("To forge items use the metal you wish to work with the anvil.");
break;
}
break;
}
return true;
}
@Override
public Location getDestination(Node n, Node node) {
if (node instanceof NPC) {
if (node.getId() == 834) {
return new Location(3169, 3045, 0);
}
}
return null;
}
}

View file

@ -0,0 +1,196 @@
package plugin.interaction.city;
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.free.gather.SkillingTool;
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.player.Player;
import org.crandor.game.node.entity.player.link.diary.DiaryType;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.node.object.ObjectBuilder;
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;
/**
* Handles the Brimhaven dungeon.
* @author Emperor
*/
@InitializablePlugin
public final class BrimhavenDungeonPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(5084).getConfigurations().put("option:leave", this);
ObjectDefinition.forId(5088).getConfigurations().put("option:walk-across", this);
ObjectDefinition.forId(5090).getConfigurations().put("option:walk-across", this);
ObjectDefinition.forId(5094).getConfigurations().put("option:walk-up", this);
ObjectDefinition.forId(5096).getConfigurations().put("option:walk-down", this);
ObjectDefinition.forId(5097).getConfigurations().put("option:walk-up", this);
ObjectDefinition.forId(5098).getConfigurations().put("option:walk-down", this);
ObjectDefinition.forId(5099).getConfigurations().put("option:squeeze-through", this);
ObjectDefinition.forId(5100).getConfigurations().put("option:squeeze-through", this);
ObjectDefinition.forId(5103).getConfigurations().put("option:chop-down", this);
ObjectDefinition.forId(5104).getConfigurations().put("option:chop-down", this);
ObjectDefinition.forId(5105).getConfigurations().put("option:chop-down", this);
ObjectDefinition.forId(5106).getConfigurations().put("option:chop-down", this);
ObjectDefinition.forId(5107).getConfigurations().put("option:chop-down", this);
ObjectDefinition.forId(5110).getConfigurations().put("option:jump-from", this);
ObjectDefinition.forId(5111).getConfigurations().put("option:jump-from", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
final GameObject object = (GameObject) node;
switch (object.getId()) {
case 5084:
player.getProperties().setTeleportLocation(Location.create(2745, 3152, 0));
return true;
case 5103:
case 5104:
case 5105:
case 5106:
case 5107:
int level = 10 + ((object.getId() - 5103) * 6);
if (player.getSkills().getLevel(Skills.WOODCUTTING) < level) {
player.getPacketDispatch().sendMessage("You need a woodcutting level of " + level + " to chop down this vine.");
return true;
}
SkillingTool tool = SkillingTool.getHatchet(player);
if (tool == null) {
player.getPacketDispatch().sendMessage("You don't have an axe to cut these vines.");
return true;
}
player.animate(tool.getAnimation());
player.getPulseManager().run(new Pulse(3, player) {
@Override
public boolean pulse() {
if (ObjectBuilder.replace(object, object.transform(0), 2)) {
Location destination = getVineDestination(player, object);
player.lock(3);
player.getWalkingQueue().reset();
if (!player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).isComplete(1, 8)) {
player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).updateTask(player, 1, 8, true);
}
player.getWalkingQueue().addPath(destination.getX(), destination.getY(), true);
}
return true;
}
});
return true;
case 5110:
case 5111:
if (player.getSkills().getLevel(Skills.AGILITY) < 12) {
player.getPacketDispatch().sendMessage("You need an agility level of 12 to cross this.");
return true;
}
player.lock(12);
final Direction dir = AgilityHandler.forceWalk(player, -1, player.getLocation(), object.getLocation(), Animation.create(769), 10, 0, null).getDirection();
GameWorld.submit(new Pulse(3, player) {
int stage = dir == Direction.NORTH ? -1 : 0;
Direction direction = dir;
@Override
public boolean pulse() {
Location l = player.getLocation();
switch (stage++) {
case 1:
direction = Direction.get(direction.toInteger() + 1 & 3);
break;
case 3:
direction = Direction.get(direction.toInteger() - 1 & 3);
break;
case 5:
if (direction == Direction.NORTH) {
return true;
}
}
if (stage == 6) {
if (!player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).isComplete(1, 9)) {
player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).updateTask(player, 1, 9, true);
}
}
AgilityHandler.forceWalk(player, -1, l, l.transform(direction), Animation.create(769), 10, 0, null);
return stage == 6;
}
});
player.addExtension(LogoutTask.class, new LocationLogoutTask(13, player.getLocation()));
return true;
case 5094:
ClimbActionHandler.climb(player, null, Location.create(2643, 9594, 2));
return true;
case 5096:
ClimbActionHandler.climb(player, null, Location.create(2649, 9591, 0));
return true;
case 5097:
if (!player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).isComplete(1, 10)) {
player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).updateTask(player, 1, 10, true);
}
ClimbActionHandler.climb(player, null, Location.create(2636, 9510, 2));
return true;
case 5098:
ClimbActionHandler.climb(player, null, Location.create(2636, 9517, 0));
return true;
case 5088:
if (player.getSkills().getLevel(Skills.AGILITY) < 30) {
player.getPacketDispatch().sendMessage("You need an agility level of 30 to cross this.");
return true;
}
AgilityHandler.walk(player, -1, player.getLocation(), Location.create(2687, 9506, 0), Animation.create(155), 0, null);
return true;
case 5090:
if (player.getSkills().getLevel(Skills.AGILITY) < 30) {
player.getPacketDispatch().sendMessage("You need an agility level of 30 to cross this.");
return true;
}
AgilityHandler.walk(player, -1, player.getLocation(), Location.create(2682, 9506, 0), Animation.create(155), 0, null);
return true;
case 5099:
case 5100:
level = object.getId() == 5099 ? 34 : 22;
if (player.getSkills().getLevel(Skills.AGILITY) < level) {
player.getPacketDispatch().sendMessage("You need an agility level of " + level + " to squeeze through the pipe.");
return true;
}
final Direction direction = Direction.get(object.getRotation() + 1 & 3);
player.lock(12);
Location l = player.getLocation();
AgilityHandler.forceWalk(player, -1, l, l = l.transform(direction, 3), Animation.create(749), 10, 0, null);
AgilityHandler.forceWalk(player, -1, l, l = l.transform(direction, 2), Animation.create(844), 10, 0, null, 5);
AgilityHandler.forceWalk(player, -1, l, l = l.transform(direction, 2), Animation.create(748), 20, 0, null, 8);
player.addExtension(LogoutTask.class, new LocationLogoutTask(12, player.getLocation()));
return true;
}
return false;
}
/**
* Gets the destination for chopping vines.
* @param player The player.
* @param object The object.
* @return The destination location.
*/
private static Location getVineDestination(Player player, GameObject object) {
if (object.getRotation() % 2 != 0) {
if (player.getLocation().getX() > object.getLocation().getX()) {
return object.getLocation().transform(-1, 0, 0);
}
return object.getLocation().transform(1, 0, 0);
}
if (player.getLocation().getY() > object.getLocation().getY()) {
return object.getLocation().transform(0, -1, 0);
}
return object.getLocation().transform(0, 1, 0);
}
}

View file

@ -0,0 +1,37 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.ClimbActionHandler;
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.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the burthorpe plugin.
* @author Emperor
*/
@InitializablePlugin
public final class BurthorpePlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(4627).getConfigurations().put("option:climb-up", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
GameObject object = (GameObject) node;
switch (object.getId()) {
case 4627:
ClimbActionHandler.climb(player, null, Location.create(2899, 3565, 0));
return true;
}
return false;
}
}

View file

@ -0,0 +1,53 @@
package plugin.interaction.city;
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.game.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle nodes related to camelot.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class CamelotNodePlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(26017).getConfigurations().put("option:climb-down", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final int id = ((GameObject) node).getId();
switch (id) {
case 26017:
player.getPacketDispatch().sendMessage("Court is not in session.");
break;
}
return true;
}
@Override
public Location getDestination(Node node, Node n) {
if (n instanceof GameObject) {
int id = ((GameObject) n).getId();
switch (id) {
case 993:
if (node.getLocation().getX() <= 2638) {
return Location.create(2637, 3350, 0);
} else {
return Location.create(2640, 3350, 0);
}
}
}
return null;
}
}

View file

@ -0,0 +1,250 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.dialogue.FacialExpression;
import org.crandor.game.content.global.action.ClimbActionHandler;
import org.crandor.game.content.global.action.DoorActionHandler;
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.player.Player;
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.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.map.path.Pathfinder;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle node interactions at draynor manor.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class DraynorManorPlugin extends OptionHandler {
/**
* Represents the lever animation.
*/
private static final Animation LEVER_ANIMATION = new Animation(834);
/**
* Represents the basement location.
*/
private static final Location BASEMENT = new Location(3117, 9753, 0);
/**
* Represents the digging animation.
*/
private static final Animation DIG_ANIM = new Animation(830);
/**
* Represents the searching animation.
*/
private static final Animation SEARCH_ANIM = new Animation(881);
/**
* Represents the spade item.
*/
private static final Item SPADE = new Item(952);
/**
* Represents the key item.
*/
private static final Item KEY = new Item(275);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(156).getConfigurations().put("option:search", this);
ObjectDefinition.forId(155).getConfigurations().put("option:search", this);
ObjectDefinition.forId(160).getConfigurations().put("option:pull", this);
ObjectDefinition.forId(131).getConfigurations().put("option:open", this);
ObjectDefinition.forId(133).getConfigurations().put("option:climb-down", this);
ObjectDefinition.forId(134).getConfigurations().put("option:open", this);
ObjectDefinition.forId(135).getConfigurations().put("option:open", this);
ObjectDefinition.forId(152).getConfigurations().put("option:search", this);
ObjectDefinition.forId(153).getConfigurations().put("option:search", this);
ObjectDefinition.forId(11498).getConfigurations().put("option:climb-up", this);
ObjectDefinition.forId(37703).getConfigurations().put("option:squeeze-through", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
int id = ((GameObject) node).getId();
switch (id) {
case 11498:
ClimbActionHandler.climb(player, new Animation(828), Location.create(3108, 3366, 1));
break;
case 160:
case 156:
case 155:
handleBookCase(player, ((GameObject) node));
break;
case 133:
ClimbActionHandler.climb(player, new Animation(827), BASEMENT);
break;
case 134:// big doors
case 135:
if (player.getLocation().getY() >= 3354) {
player.getPacketDispatch().sendMessage("The doors won't open.");
return true;
}
player.getPacketDispatch().sendMessage("The doors slam shut behind you.");
DoorActionHandler.handleDoor(player, (GameObject) node);
return true;
case 131:
if (!player.getInventory().containsItem(KEY)) {
player.getPacketDispatch().sendMessage("The door is locked.");
} else {
DoorActionHandler.handleAutowalkDoor(player, (GameObject) node);
}
break;
case 152:
if (!player.getInventory().containsItem(SPADE)) {
player.getDialogueInterpreter().sendDialogues(player, FacialExpression.ANGRY, "I'm not looking through that with my hands!");
return true;
}
player.lock(3);
player.animate(DIG_ANIM);
player.getPacketDispatch().sendMessage("You dig throug the compost...");
if (!player.getInventory().containsItem(KEY)) {
player.getPacketDispatch().sendMessage("... and find a small key.");
if (!player.getInventory().add(KEY)) {
GroundItemManager.create(KEY, player);
}
} else {
player.getPacketDispatch().sendMessage("... but you find nothing of interest.");
}
break;
case 153:
player.lock(3);
player.animate(SEARCH_ANIM);
player.getDialogueInterpreter().open(3954922);
break;
case 37703:
AgilityHandler.walk(player, 0, player.getLocation(), node.getLocation().transform(player.getLocation().getX() <= 3085 ? 1 : 0, 0, 0), new Animation(1426), 0, null);
break;
}
return true;
}
/**
* Method used to handle the secret book case opening.
* @param player the player.
*/
private final void handleBookCase(final Player player, final GameObject object) {
Location dest = null;
if (RegionManager.getObject(Location.create(3097, 3359, 0)) == null || RegionManager.getObject(Location.create(3097, 3358, 0)) == null) {
return;
}
if (player.getLocation().getX() > 3096) {
if (player.getLocation().getY() >= 3359) {
dest = Location.create(3096, 3359, 0);
} else {
dest = Location.create(3096, 3358, 0);
}
} else {
if (object.getId() != 160) {
return;
}
if (player.getLocation().getY() >= 3359) {
dest = Location.create(3098, 3359, 0);
} else {
dest = Location.create(3098, 3358, 0);
}
}
final Location destination = dest;
if (object.getId() == 160) {
GameWorld.submit(new Pulse(1, player) {
int counter = 0;
@Override
public boolean pulse() {
switch (counter++) {
case 1:
player.getPacketDispatch().sendMessage("The lever opens the secret door!");
player.animate(LEVER_ANIMATION);
break;
case 2:
ObjectBuilder.replace(object, object.transform(161), 6);
break;
case 3:
Pathfinder.find(player, Location.create(3096, 3358, 0)).walk(player);
break;
case 4:
player.faceLocation(destination);
break;
case 5:
ObjectBuilder.remove(RegionManager.getObject(Location.create(3097, 3359, 0)));
ObjectBuilder.remove(RegionManager.getObject(Location.create(3097, 3358, 0)));
ObjectBuilder.add(new GameObject(156, new Location(3097, 3357, 0)));
ObjectBuilder.add(new GameObject(157, new Location(3097, 3360, 0)));
break;
case 6:
AgilityHandler.walk(player, -1, player.getLocation(), destination, null, 0.0, null);
break;
case 8:
ObjectBuilder.remove(RegionManager.getObject(new Location(3097, 3360, 0)));
ObjectBuilder.remove(RegionManager.getObject(new Location(3097, 3357, 0)));
ObjectBuilder.add(new GameObject(155, new Location(3097, 3359, 0)));
ObjectBuilder.add(new GameObject(156, new Location(3097, 3358, 0)));
break;
}
return false;
}
});
return;
}
GameWorld.submit(new Pulse(1, player) {
int count = 0;
@Override
public boolean pulse() {
switch (count) {
case 0:
player.getPacketDispatch().sendMessage("You've found a secret door!");
ObjectBuilder.remove(RegionManager.getObject(Location.create(3097, 3359, 0)));
ObjectBuilder.remove(RegionManager.getObject(Location.create(3097, 3358, 0)));
ObjectBuilder.add(new GameObject(156, new Location(3097, 3357, 0)));
ObjectBuilder.add(new GameObject(157, new Location(3097, 3360, 0)));
break;
case 1:
AgilityHandler.walk(player, -1, player.getLocation(), destination, null, 0.0, null);
break;
case 3:
ObjectBuilder.remove(RegionManager.getObject(new Location(3097, 3360, 0)));
ObjectBuilder.remove(RegionManager.getObject(new Location(3097, 3357, 0)));
ObjectBuilder.add(new GameObject(155, new Location(3097, 3359, 0)));
ObjectBuilder.add(new GameObject(156, new Location(3097, 3358, 0)));
break;
}
count++;
return count == 4;
}
});
}
@Override
public Location getDestination(Node node, Node n) {
if (n instanceof GameObject) {
final int id = ((GameObject) n).getId();
switch (id) {
case 155:
return Location.create(3098, 3359, 0);
case 156:
return Location.create(3098, 3358, 0);
case 160:
return Location.create(3096, 3357, 0);
}
}
return null;
}
}

View file

@ -0,0 +1,244 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.NPCDefinition;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.component.Component;
import org.crandor.game.content.activity.ActivityManager;
import org.crandor.game.content.activity.ActivityPlugin;
import org.crandor.game.content.activity.CutscenePlugin;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.global.action.ClimbActionHandler;
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.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.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.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the node plugin used to handle draynor interactions.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class DraynorNodePlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.forId(922).getConfigurations().put("option:make-dyes", this);
ObjectDefinition.forId(7092).getConfigurations().put("option:observe", this);
ObjectDefinition.forId(6434).getConfigurations().put("option:open", this);
ActivityManager.register(new TelescopeCutscene());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final int id = node instanceof NPC ? ((NPC) node).getId() : ((GameObject) node).getId();
switch (id) {
case 922:
player.getDialogueInterpreter().open(((NPC) node).getId(), ((NPC) node), true);
break;
case 7092:
ActivityManager.start(player, "draynor telescope", false);
break;
case 6434:
ClimbActionHandler.climb(player, null, Location.create(3085, 9672, 0));
break;
case 32016:
ClimbActionHandler.climb(player, null, Location.create(3084, 3271, 0));
}
return true;
}
@Override
public Location getDestination(Node node, Node n) {
if (n instanceof GameObject) {
final GameObject object = (GameObject) n;
if (object.getId() == 7092) {
return n.getLocation().transform(0, 1, 0);
}
}
return null;
}
/**
* Represents the telescope cutscene.
* @author 'Vexia
* @version 1.0
*/
public static final class TelescopeCutscene extends CutscenePlugin {
/**
* Represents the telescope interface.
*/
private static final Component INTERFACE = new Component(386);
/**
* Represents the animation used to look into a telescope.
*/
private static final Animation TELESCOPE_ANIM = new Animation(2171);
/**
* Constructs a new {@code TelescopeCutscene} {@code Object}.
*/
public TelescopeCutscene() {
super("draynor telescope");
}
/**
* Constructs a new {@code TelescopeCutscene} {@code Object}.
* @param player the player.
*/
public TelescopeCutscene(Player player) {
super("draynor telescope");
this.player = player;
}
@Override
public ActivityPlugin newInstance(Player p) throws Throwable {
return new TelescopeCutscene(p);
}
@Override
public boolean start(final Player player, boolean login, Object... args) {
player.animate(TELESCOPE_ANIM);
player.getDialogueInterpreter().sendPlainMessage(true, "You look through the telescope...");
return super.start(player, login, args);
}
@Override
public void open() {
player.setAttribute("cutscene:original-loc", Location.create(3088, 3254, 0));
player.setDirection(Direction.NORTH);
player.faceLocation(player.getLocation().transform(0, 1, 0));
int x = 3104;
int y = 3175;
int height = 900;
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.POSITION, x, y, height, 1, 100));
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.ROTATION, x + 1, y - 30, height, 1, 100));
x = 3111;
y = 3172;
height = 700;
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.POSITION, x, y, height, 1, 2));
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.ROTATION, x - 1, y + 230, height, 1, 1));
player.getInterfaceManager().open(INTERFACE);
GameWorld.submit(new Pulse(22, player) {
@Override
public boolean pulse() {
TelescopeCutscene.this.stop(true);
return true;
}
});
}
@Override
public void register() {
super.register();
new EndDialogue().init();
}
@Override
public void end() {
player.getInterfaceManager().close();
player.getDialogueInterpreter().open(32389023);
super.end();
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public Location getStartLocation() {
return new Location(3104, 3175, 0);
}
@Override
public void configure() {
}
/**
* Represents the ending dialogue.
* @author 'Vexia
* @version 1.0
*/
public static final class EndDialogue extends DialoguePlugin {
/**
* Constructs a new {@code EndDialogue} {@code Object}.
* @param player the player.
*/
public EndDialogue(final Player player) {
super(player);
}
/**
* Constructs a new {@code EndDialogue} {@code Object}.
*/
public EndDialogue() {
/**
* empty.
*/
}
@Override
public DialoguePlugin newInstance(Player player) {
return new EndDialogue(player);
}
@Override
public boolean open(Object... args) {
player("I see you've got your telescope", "pointing at the Wizard's Tower.");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
interpreter.sendDialogues(3820, null, "Oh, do I? Well, why does that interest you?");
stage = 1;
break;
case 1:
player("Well, you robbed a bank, and I bet you're now", "planning something to do with that Tower!");
stage = 2;
break;
case 2:
interpreter.sendDialogues(3820, null, "No, no, I'm not planning anything like that again.");
stage = 3;
break;
case 3:
player("Well I'll be watching you...");
stage = 4;
break;
case 4:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 32389023 };
}
}
}
}

View file

@ -0,0 +1,46 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.ClimbActionHandler;
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.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle edgeville related interactions.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class EdgevilleNodePlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(9262).getConfigurations().put("option:take-seed", this);
ObjectDefinition.forId(9261).getConfigurations().put("option:take-seed", this);
ObjectDefinition.forId(30806).getConfigurations().put("option:take-seed", this);
ObjectDefinition.forId(12265).getConfigurations().put("option:climb", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
int id = ((GameObject) node).getId();
switch (id) {
case 9262:
case 9261:
case 30806:
player.getPacketDispatch().sendMessage("There doesn't seem to be any seeds on this rosebush.");
break;
case 12265:
ClimbActionHandler.climb(player, null, Location.create(3078, 3493, 0));
break;
}
return true;
}
}

View file

@ -0,0 +1,49 @@
package plugin.interaction.city;
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.world.map.Location;
import org.crandor.game.world.repository.Repository;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents a plugin used to handle entrana related objects.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class EntranaObjectPlugin extends OptionHandler {
/**
* Represents the location to teleport to.
*/
private static final Location LOCATION = Location.create(3208, 3764, 0);// magic
// door
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(2408).getConfigurations().put("option:climb-down", this);
ObjectDefinition.forId(2407).getConfigurations().put("option:open", this);// magic
// door
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (option) {
case "climb-down":
player.getDialogueInterpreter().open(656, Repository.findNPC(656));
break;
case "open":
player.getPacketDispatch().sendMessage("You feel the world around you dissolve...");
player.getProperties().setTeleportLocation(LOCATION);
break;
}
return true;
}
}

View file

@ -0,0 +1,177 @@
package plugin.interaction.city;
import java.util.List;
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.global.action.DoorActionHandler;
import org.crandor.game.content.global.action.PickupHandler;
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.impl.ForceMovement;
import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player;
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.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;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle node interactions in falador.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class FaladorNodePlugin extends OptionHandler {
/**
* Represents the opening of a cupboard animation.
*/
private static final Animation OPEN_ANIMATION = new Animation(536);
/**
* Represents the closing of a cupboard animation.
*/
private static final Animation CLOSE_ANIMATION = new Animation(535);
/**
* Represents the portrait item.
*/
private static final Item PORTRAIT = new Item(666);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(2271).getConfigurations().put("option:open", this);// sir
// vyvans
// cupboard
// (closed)
ObjectDefinition.forId(2272).getConfigurations().put("option:shut", this);// sir
// vyvans
// cupboard
// (open)
ObjectDefinition.forId(2272).getConfigurations().put("option:search", this);// sir
// vyvans
// cupboard
// (open)
// dwarven mine
ObjectDefinition.forId(30868).getConfigurations().put("option:squeeze-through", this);
ObjectDefinition.forId(5020).getConfigurations().put("option:ride", this);
ItemDefinition.forId(245).getConfigurations().put("option:take", this);
// fally park.
NPCDefinition.forId(2290).getConfigurations().put("option:talk-to", this);
ObjectDefinition.forId(11708).getConfigurations().put("option:close", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
final int id = node instanceof GameObject ? ((GameObject) node).getId() : node instanceof NPC ? ((NPC) node).getId() : ((Item) node).getId();
switch (id) {
case 11708:// estate door.
DoorActionHandler.handleDoor(player, (GameObject) node);
break;
case 2290:
player.getDialogueInterpreter().open(id, node);
return true;
case 245:
if (node.getLocation().equals(new Location(2931, 3515, 0))) {
final List<NPC> npcs = RegionManager.getLocalNpcs(player);
for (NPC n : npcs) {
if (n.getId() == 188) {
n.sendChat("Hands off zamorak's wine!");
n.getProperties().getCombatPulse().attack(player);
}
}
} else {
return PickupHandler.take(player, (GroundItem) node);
}
break;
case 5020:
player.getDialogueInterpreter().sendDialogue("You must visit Keldagrim before you are allowed to ride mine carts.");
break;
case 30868:
if (player.getSkills().getLevel(Skills.AGILITY) < 42) {
player.getPacketDispatch().sendMessage("You need an agility level of 42 to do this.");
return true;
}
Location dest = player.getLocation().equals(new Location(3035, 9806, 0)) ? new Location(3028, 9806, 0) : new Location(3035, 9806, 0);
player.animate(new Animation(2240));
ForceMovement movement = new ForceMovement(player, player.getLocation(), dest, new Animation(2240)) {
@Override
public void stop() {
super.stop();
}
};
movement.run(player, 8);
GameWorld.submit(new Pulse(7, player) {
@Override
public boolean pulse() {
player.animate(new Animation(2240));
return true;
}
});
break;
case 2271:
ObjectBuilder.replace((GameObject) node, ((GameObject) node).transform(2272));
player.animate(OPEN_ANIMATION);
break;
case 2272:
switch (option) {
case "shut":
ObjectBuilder.replace((GameObject) node, ((GameObject) node).transform(2271));
player.animate(CLOSE_ANIMATION);
break;
case "search":
if (player.getInventory().containsItem(PORTRAIT)) {
player.getDialogueInterpreter().sendDialogue("There is just a load of junk in here.");
return true;
} else {
if (!player.getInventory().add(PORTRAIT)) {
GroundItemManager.create(PORTRAIT, player);
}
player.getDialogueInterpreter().sendDialogue("You find a small portrait in here which you take.");
}
break;
}
break;
}
return true;
}
@Override
public Location getDestination(Node node, Node n) {
if (n instanceof NPC) {
final NPC npc = (NPC) n;
if (npc.getId() == 2290) {
return Location.create(2997, 3374, 0);
}
} else if (n instanceof GameObject) {
if (n.getId() == 11708 && node.getLocation().equals(new Location(2981, 3370, 0))) {
return node.getLocation();
}
}
return null;
}
@Override
public boolean isWalk() {
return false;
}
@Override
public boolean isWalk(final Player player, Node node) {
return !(node instanceof Item);
}
}

View file

@ -0,0 +1,111 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
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.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.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles Gnome stronghold options.
* @author Emperor
*/
@InitializablePlugin
public final class GnomeStrongholdPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(190).getConfigurations().put("option:open", this);
ObjectDefinition.forId(1967).getConfigurations().put("option:open", this);
ObjectDefinition.forId(1968).getConfigurations().put("option:open", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
GameObject object = (GameObject) node;
switch (object.getId()) {
case 1967:
case 1968:
openTreeDoor(player, object);
return true;
case 190:
openGates(player, object);
return true;
}
return true;
}
/**
* Opens the tree doors.
* @param player the player.
* @param object the object.
*/
private void openTreeDoor(final Player player, final GameObject object) {
if (object.getCharge() == 88) {
return;
}
object.setCharge(88);
ObjectBuilder.replace(object, object.transform(object.getId() == 1967 ? 1969 : 1970), 4);
AgilityHandler.walk(player, -1, player.getLocation(), player.getLocation().transform(0, player.getLocation().getY() <= 3491 ? 2 : -2, 0), new Animation(1426), 0, null);
GameWorld.submit(new Pulse(4) {
@Override
public boolean pulse() {
object.setCharge(1000);
return true;
}
});
}
/**
* Opens the stronghold gates.
* @param player The player.
* @param object The door.
*/
private void openGates(Player player, final GameObject object) {
if (object.getCharge() == 88) {
return;
}
object.setCharge(88);
ObjectBuilder.replace(object, object.transform(191), 4);
ObjectBuilder.add(new GameObject(192, Location.create(2462, 3383, 0)), 4);
Location start = Location.create(2461, 3382, 0);
Location end = Location.create(2461, 3385, 0);
if (player.getLocation().getY() > object.getLocation().getY()) {
Location s = start;
start = end;
end = s;
}
AgilityHandler.walk(player, -1, start, end, new Animation(1426), 0, null);
GameWorld.submit(new Pulse(4) {
@Override
public boolean pulse() {
object.setCharge(1000);
return true;
}
});
}
@Override
public Location getDestination(Node node, Node n) {
if (n instanceof GameObject) {
switch (((GameObject) n).getId()) {
case 190:
if (node.getLocation().getY() < n.getLocation().getY()) {
return Location.create(2461, 3382, 0);
}
return Location.create(2461, 3385, 0);
}
}
return null;
}
}

View file

@ -0,0 +1,115 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.ClimbActionHandler;
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.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.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.RandomFunction;
/**
* Represents the ham hide out node interaction plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class HamHideoutPlugin extends OptionHandler {
/**
* Represents the animation to use.
*/
private static final Animation ANIMATION = new Animation(827);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(5490).getConfigurations().put("option:open", this);
ObjectDefinition.forId(5490).getConfigurations().put("option:pick-lock", this);
ObjectDefinition.forId(5491).getConfigurations().put("option:close", this);
ObjectDefinition.forId(5491).getConfigurations().put("option:climb-down", this);
ObjectDefinition.forId(5493).getConfigurations().put("option:climb-up", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
final int id = ((GameObject) node).getId();
switch (id) {
case 5493:
if (player.getLocation().withinDistance(Location.create(3149, 9652, 0))) {
ClimbActionHandler.climb(player, new Animation(828), new Location(3165, 3251, 0));
return true;
}
ClimbActionHandler.climbLadder(player, (GameObject) node, option);
return true;
case 5490:
case 5491:
switch (option) {
case "open":
if (player.getConfigManager().get(174) == 0) {
player.getPacketDispatch().sendMessage("This trapdoor seems totally locked.");
} else {
player.getConfigManager().set(346, 272731282);
ClimbActionHandler.climb(player, new Animation(827), new Location(3149, 9652, 0));
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
player.getConfigManager().set(174, 0);
return true;
}
});
}
break;
case "close":
player.getConfigManager().set(174, 0);
break;
case "climb-down":
switch (id) {
case 5491:
if (!player.getAchievementDiaryManager().getDiary(DiaryType.LUMBRIDGE).isComplete(0, 9)) {
player.getAchievementDiaryManager().getDiary(DiaryType.LUMBRIDGE).updateTask(player, 0, 9, true);
}
player.getProperties().setTeleportLocation(Location.create(3149, 9652, 0));
break;
}
break;
case "pick-lock":
player.lock(3);
player.animate(ANIMATION);
player.getPacketDispatch().sendMessage("You attempt to pick the lock on the trap door.");
GameWorld.submit(new Pulse(2, player) {
@Override
public boolean pulse() {
player.animate(ANIMATION);
player.getPacketDispatch().sendMessage("You attempt to pick the lock on the trap door.");
boolean success = RandomFunction.random(3) == 1;
player.getPacketDispatch().sendMessage(success ? ("You pick the lock on the trap door.") : "You fail to pick the lock - your fingers get numb from fumbling with the lock.");
player.unlock();
if (success) {
player.getConfigManager().set(174, 1 << 14);
GameWorld.submit(new Pulse(40, player) {
@Override
public boolean pulse() {
player.getConfigManager().set(174, 0);
return true;
}
});
}
return true;
}
});
break;
}
break;
}
return true;
}
}

View file

@ -0,0 +1,34 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.NPCDefinition;
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;
/**
* Package -> plugin.interaction.city
* Created on -> 9/10/2016 @10:42 PM for 530
*
* @author Ethan Kyle Millard
*/
@InitializablePlugin
public class HomePlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.forId(552).getConfigurations().put("talk-to", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (node.getId()) {
case 552:
player.getDialogueInterpreter().open(552);
break;
}
return false;
}
}

View file

@ -0,0 +1,280 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.NPCDefinition;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.component.Component;
import org.crandor.game.content.dialogue.FacialExpression;
import org.crandor.game.content.global.action.ClimbActionHandler;
import org.crandor.game.content.global.action.DoorActionHandler;
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.entity.player.link.diary.DiaryType;
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.Location;
import org.crandor.game.world.repository.Repository;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the option plugin used to handle karamaja options.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class KaramajaOptionPlugin extends OptionHandler {
/**
* Represents the banana item.
*/
private static final Item BANANA = new Item(1963);
/**
* Represents the pineapple item.
*/
private static final Item PINEAPPLE = new Item(2114);
/**
* Represents the pine apple objects.
*/
private static final int[] PINEAPPLE_OBJECTS = new int[] { 1408, 1409, 1410, 1411, 1412, 1413 };
/**
* Represents the musa point dungeon.
*/
private static final Location MUSA_POINT_DUNGEON = Location.create(2856, 9567, 0);
/**
* Represents the volacno rim location.
*/
private static final Location VOLCANO_RIM = new Location(2856, 3167, 0);
/**
* Represents the agility brimhaven location.
*/
private static final Location AGILITY_LOCATION = new Location(2805, 9589, 3);
/**
* Represents the main base asgility location (ground floor)
*/
private static final Location AGILITY_MAIN = new Location(2809, 3193, 0);
/**
* Represents the component.
*/
private static final Component TICKET_EXCHANGE = new Component(6);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(2072).getConfigurations().put("option:search", this);// banana
// crate.
ObjectDefinition.forId(2072).getConfigurations().put("option:fill", this);// banana
// crate.
ObjectDefinition.forId(2078).getConfigurations().put("option:search", this);// random
// crate.
ObjectDefinition.forId(492).getConfigurations().put("option:climb-down", this);// musa
// point
// rock
ObjectDefinition.forId(1764).getConfigurations().put("option:climb", this);// musa
// dungeon
// rope
ObjectDefinition.forId(3617).getConfigurations().put("option:climb-down", this);// agility
// ladder
ObjectDefinition.forId(3618).getConfigurations().put("option:climb-up", this);// agility
// ladder
NPCDefinition.forId(437).getConfigurations().put("option:pay", this);// capn
// izzy.
NPCDefinition.forId(1055).getConfigurations().put("option:trade", this);// capn
// izzy
// trader
// (tickets)
ObjectDefinition.forId(2626).getConfigurations().put("option:open", this);// grubors
// locked
// door.
ObjectDefinition.forId(2628).getConfigurations().put("option:open", this);// the
// shrimp
// and
// parrot
// door(chef)
ObjectDefinition.forId(2627).getConfigurations().put("option:open", this);// garv
// door
ObjectDefinition.forId(1591).getConfigurations().put("option:open", this);// garv
// door
NPCDefinition.forId(1178).getConfigurations().put("option:fish", this);// lubufu
// fishing
// spot
ObjectDefinition.forId(5083).getConfigurations().put("option:enter", this);// sanibo
// dungeon
// entrance.
ObjectDefinition.forId(2439).getConfigurations().put("option:open", this);
for (int pineapple : PINEAPPLE_OBJECTS) {
ObjectDefinition.forId(pineapple).getConfigurations().put("option:pick", this);// pineapple
// picking.
}
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (option) {
case "pick":// pineapples.
if (player.getInventory().freeSlots() == 0) {
player.getPacketDispatch().sendMessage("Not enough inventory space.");
return true;
}
final GameObject pineApple = ((GameObject) node);
if (pineApple.getId() == 1413) {
player.getPacketDispatch().sendMessage("There are no pineapples left on this plant.");
return true;
}
boolean last = pineApple.getId() == 14012;
if (player.getInventory().add(PINEAPPLE)) {
ObjectBuilder.replace(pineApple, pineApple.transform(pineApple.getId() + 1), last ? 270 : 40);
player.getPacketDispatch().sendMessage("You pick a pineapple.");
}
break;
case "enter":
switch (((GameObject) node).getId()) {
case 5083:
if (player.getAttribute("saniboch:paid", false) || player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).isComplete()) {
ClimbActionHandler.climb(player, ClimbActionHandler.CLIMB_UP, Location.create(2713, 9564, 0));
player.removeAttribute("saniboch:paid");
break;
}
player.getDialogueInterpreter().sendDialogues(1595, null, "You can't go in there without paying!");
break;
}
break;
case "trade":
switch (((NPC) node).getId()) {
case 1055:
player.getInterfaceManager().open(TICKET_EXCHANGE);
break;
}
break;
case "fish":
player.getDialogueInterpreter().sendDialogues(1171, FacialExpression.ANGRY, "Keep off my fishing spot, whippersnapper!");
break;
case "pay":
if (!player.getAttribute("capn_izzy", false)) {
if (player.getInventory().contains(995, 200) && player.getInventory().remove(new Item(995, 200))) {
player.getDialogueInterpreter().sendItemMessage(new Item(995, 200), "You give Cap'n Izzy the 200 coin entrance fee.");
player.getPacketDispatch().sendMessage("You give Cap'n Izzy the 200 coin entrance fee.");
player.setAttribute("/save:capn_izzy", true);
return true;
} else {
player.getPacketDispatch().sendMessage("You don't have the 200 coin entrance fee.");
}
} else {
player.getDialogueInterpreter().sendDialogues(437, null, "Avast there, ye've already paid!");
}
break;
case "pay-fare":
switch (((GameObject) node).getId()) {
case 2230:
player.getPacketDispatch().sendMessage("This cart appears to have been out of reward for some time.");
break;
}
break;
case "climb-up":
switch (((GameObject) node).getId()) {
case 3618:
player.getProperties().setTeleportLocation(AGILITY_MAIN);
break;
}
break;
case "climb-down":
switch (((GameObject) node).getId()) {
case 492:
player.getPacketDispatch().sendMessage("You climb down through the pot hole.");
player.getProperties().setTeleportLocation(MUSA_POINT_DUNGEON);
break;
case 3617:
if (!player.getAttribute("capn_izzy", false)) {
player.getDialogueInterpreter().open(437, Repository.findNPC(437), true);
return true;
}
player.removeAttribute("capn_izzy");
player.getProperties().setTeleportLocation(AGILITY_LOCATION);
break;
}
break;
case "climb":
switch (((GameObject) node).getId()) {
case 1764:
player.getProperties().setTeleportLocation(VOLCANO_RIM);
player.getPacketDispatch().sendMessage("You climb up the hanging rope...");
player.getPacketDispatch().sendMessage("You appear on the volcano rim.");
break;
}
break;
case "open":
switch (((GameObject) node).getId()) {
case 2626:
player.getDialogueInterpreter().open(789, Repository.findNPC(789));
break;
case 2628:
player.getPacketDispatch().sendMessage("The door is securely closed.");
break;
case 2627:
player.getDialogueInterpreter().open(788, Repository.findNPC(788), true);
break;
case 1591:
player.getPacketDispatch().sendMessage("You try and open the door...");
player.getPacketDispatch().sendMessage("The door is locked tight, I can't open it.");
break;
case 2439:
player.getPacketDispatch().sendMessage("The gate doesn't open.");
break;
}
break;
case "search":
switch (((GameObject) node).getId()) {
case 2078:
player.getPacketDispatch().sendMessage("There are no bananas left on the tree.");
break;
case 2072:
int amt = player.getSavedData().getGlobalData().getKaramjaBananas();
if (amt >= 10) {
player.getPacketDispatch().sendMessage("The crate is full of bananas.");
return true;
}
if (amt == 0) {
player.getPacketDispatch().sendMessage("The crate is completely empty.");
} else {
player.getPacketDispatch().sendMessage("The crate has " + amt + " banana " + (amt > 1 ? "s" : "") + "inside.");
}
break;
}
break;
case "fill":
if (player.getSavedData().getGlobalData().isLuthasTask()) {
int bananas = player.getInventory().getAmount(BANANA);
if (bananas > 0) {
player.getDialogueInterpreter().sendDialogue("You pack all your bananas into the crate.");
if (player.getInventory().remove(new Item(BANANA.getId(), bananas))) {
player.getSavedData().getGlobalData().setKaramjaBannanas(bananas + player.getSavedData().getGlobalData().getKaramjaBananas());
}
}
} else {
player.getPacketDispatch().sendMessage("I don't know what goes in there.");
}
break;
}
return true;
}
@Override
public Location getDestination(Node node, Node n) {
if (n instanceof GameObject) {
if (((GameObject) n).getDefinition().hasAction("open")) {
return DoorActionHandler.getDestination((Player) node, (GameObject) n);
}
}
return null;
}
}

View file

@ -0,0 +1,47 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.DoorActionHandler;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
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;
/**
* Handles interactions in the khardian desert.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class KhardianDesertPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(6481).getConfigurations().put("option:enter", this);
ObjectDefinition.forId(6545).getConfigurations().put("option:open", this);
ObjectDefinition.forId(6547).getConfigurations().put("option:open", this);
ObjectDefinition.forId(6551).getConfigurations().put("option:use", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (node.getId()) {
case 6481:
player.teleport(new Location(3233, 9313, 0));
break;
case 6545:
case 6547:
// player.getPacketDispatch().sendMessage("A mystical power has sealed this door...");
DoorActionHandler.handleAutowalkDoor(player, node.asObject());
break;
case 6551:
player.teleport(new Location(3233, 2887, 0));
break;
}
return true;
}
}

View file

@ -0,0 +1,180 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.activity.ActivityManager;
import org.crandor.game.content.global.action.ClimbActionHandler;
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.Entity;
import org.crandor.game.node.entity.combat.equipment.Ammunition;
import org.crandor.game.node.entity.combat.equipment.WeaponInterface;
import org.crandor.game.node.entity.impl.Projectile;
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.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the node option handler for lumbridge.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class LumbridgeNodePlugin extends OptionHandler {
/**
* If the flag is in use.
*/
private static boolean FLAG_IN_USE;
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(36978).getConfigurations().put("option:play", this);
ObjectDefinition.forId(37335).getConfigurations().put("option:raise", this);
ObjectDefinition.forId(37095).getConfigurations().put("option:shoot-at", this);
ObjectDefinition.forId(36976).getConfigurations().put("option:ring", this);
ObjectDefinition.forId(22114).getConfigurations().put("option:open", this);
ObjectDefinition.forId(29355).getConfigurations().put("option:climb-up", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
int id = ((GameObject) node).getId();
switch (id) {
case 29355:
if (node.getLocation().getX() == 3209) {
ClimbActionHandler.climb(player, ClimbActionHandler.CLIMB_UP, new Location(3210, 3216, 0));
break;
}
ClimbActionHandler.climbLadder(player, node.asObject(), "climb-up");
return true;
case 37095:
if (!player.getEquipment().contains(9706, 1) || !player.getEquipment().contains(9705, 1)) {
player.getPacketDispatch().sendMessage("You need a training bow and arrow to practice here.");
return true;
}
player.getPulseManager().run(new ArcheryTargetPulse(player, (GameObject) node));
return true;
case 36978:
player.lock();
ActivityManager.start(player, "organ cutscene", false);
return true;
case 37335:
if (!FLAG_IN_USE) {
FLAG_IN_USE = true;
player.getPacketDispatch().sendObjectAnimation(((GameObject) node), new Animation(9979));
player.sendMessage("You start cranking the lever.");
GameWorld.submit(new Pulse(1, player) {
int counter;
@Override
public boolean pulse() {
switch (counter++) {
case 7:
player.sendMessage("The flag reaches the top...");
break;
case 12:
player.sendMessage("...and slowly descends.");
break;
}
return counter >= 20;
}
@Override
public void stop() {
super.stop();
FLAG_IN_USE = false;
}
});
}
break;
case 36976:
player.getPacketDispatch().sendMessage("The towns people wouldn't appreciate you ringing their bell.");
break;
}
return true;
}
@Override
public Location getDestination(Node node, Node n) {
if (n instanceof GameObject) {
final GameObject object = (GameObject) n;
if (object.getId() == 36976) {
return Location.create(3243, 3205, 2);
} else if (object.getId() == 37095) {
return n.getLocation().transform(5, 0, 0);
}
}
return null;
}
/**
* Represents the archery target pulse.
* @author 'Vexia
* @version 1.0
*/
public static final class ArcheryTargetPulse extends Pulse {
/**
* Represents the player instance.
*/
private final Player player;
/**
* Represents the game object.
*/
private final GameObject object;
/**
* Constructs a new {@code ArcheryTargetPulse} {@code Object}.
* @param player the player.
* @param object the object.
*/
public ArcheryTargetPulse(final Player player, final GameObject object) {
super(1, player, object);
this.player = player;
this.object = object;
}
@Override
public boolean pulse() {
if (getDelay() == 1) {
setDelay(player.getProperties().getAttackSpeed());
}
if (player.getEquipment().remove(new Item(9706, 1))) {
Projectile p = Ammunition.get(9706).getProjectile().transform(player, object.getLocation());
p.setEndLocation(object.getLocation());
p.setEndHeight(25);
p.send();
player.animate(new Animation(426));
Entity entity = player;
int level = entity.getSkills().getLevel(Skills.RANGE);
int bonus = entity.getProperties().getBonuses()[14];
double prayer = 1.0;
if (entity instanceof Player) {
prayer += ((Player) entity).getPrayer().getSkillBonus(Skills.RANGE);
}
double cumulativeStr = Math.floor(level * prayer);
if (entity.getProperties().getAttackStyle().getStyle() == WeaponInterface.STYLE_RANGE_ACCURATE) {
cumulativeStr += 3;
} else if (entity.getProperties().getAttackStyle().getStyle() == WeaponInterface.STYLE_LONG_RANGE) {
cumulativeStr += 1;
}
cumulativeStr *= 1.0;
int hit = (int) ((14 + cumulativeStr + (bonus / 8) + ((cumulativeStr * bonus) * 0.016865)) * 1.0) / 10 + 1;
player.getSkills().addExperience(Skills.RANGE, ((hit * 1.33) / 10));
return !player.getEquipment().contains(9706, 1) || !player.getEquipment().contains(9705, 1);
} else {
return true;
}
}
}
}

View file

@ -0,0 +1,43 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.NPCDefinition;
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.entity.player.link.TeleportManager.TeleportType;
import org.crandor.game.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* The plugin used to handle the interactions on Lunar Isle (Moonclan island).
* @author Splinter
* @version 1.0
*/
@InitializablePlugin
public final class LunarIslePlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(16777).getConfigurations().put("option:close", this);
ObjectDefinition.forId(16774).getConfigurations().put("option:open", this);
NPCDefinition.forId(4512).getConfigurations().put("option:go-inside", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final int id = node.getId();
switch (id) {
case 16777:
case 16774:
player.getTeleporter().send(Location.create(2101, 3926, 0), TeleportType.FAIRY_RING);
break;
case 4512:
player.getTeleporter().send(Location.create(2451, 4645, 0), TeleportType.FAIRY_RING);
break;
}
return true;
}
}

View file

@ -0,0 +1,41 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.ClimbActionHandler;
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.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the edgeville monastery.
* @author Vexia
*/
@InitializablePlugin
public final class MonasteryPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(2641).getConfigurations().put("option:climb-up", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (node.getId()) {
case 2641:
final boolean abbot = node.getLocation().equals(new Location(3057, 3483, 0));
if (!player.getSavedData().getGlobalData().isJoinedMonastery()) {
player.getDialogueInterpreter().open(abbot ? 801 : 7727, true);
} else {
ClimbActionHandler.climbLadder(player, (GameObject) node, option);
}
break;
}
return true;
}
}

View file

@ -0,0 +1,146 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.NPCDefinition;
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.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.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.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.RandomFunction;
/**
* Represents the port sarim plugin.
* @author 'Vexia
* @date 30/11/2013
*/
@InitializablePlugin
public final class PortSarimPlugin extends OptionHandler {
/**
* Represents the taking animation.
*/
private static final Animation TAKE_ANIM = new Animation(832);
/**
* Represents the karamjan rum item.
*/
private static final Item KARAMJAN_RUM = new Item(431);
/**
* Represents the messages the sleeping guard can say.
*/
private static final String MESSAGES[] = new String[] { "Hmph... heh heh heh...", "Mmmm... big pint of beer... kebab...", "Mmmmmm... donuts...", "Guh.. mwww... zzzzzz..." };
/**
* Represents the entrana monks.
*/
private static final int[] MONKS = new int[] { 2728, 657, 2729, 2730, 2731, 658 };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.forId(2704).getConfigurations().put("option:talk-to", this);
ObjectDefinition.forId(9565).getConfigurations().put("option:open", this);
ObjectDefinition.forId(9565).getConfigurations().put("option:pick-lock", this);
ObjectDefinition.forId(9563).getConfigurations().put("option:open", this);
for (int i : MONKS) {
NPCDefinition.forId(i).getConfigurations().put("option:take-boat", this);
}
ObjectDefinition.forId(2071).getConfigurations().put("option:search", this);
NPCDefinition.forId(745).getConfigurations().put("option:attack", this);
ObjectDefinition.forId(33173).getConfigurations().put("option:exit", this);
ObjectDefinition.forId(33174).getConfigurations().put("option:enter", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
switch (option) {
case "enter":
player.getProperties().setTeleportLocation(Location.create(3056, 9562, 0));
player.getPacketDispatch().sendMessage("You leave the icy cavern.");
break;
case "exit":
player.getDialogueInterpreter().open(238284);
break;
case "attack":
if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) != 20) {
player.getPacketDispatch().sendMessage("The goblin is already in prison. You have no reason to attack him.");
} else {
player.getPulseManager().clear("interaction:attack:" + node.hashCode());
player.getProperties().getCombatPulse().attack(node);
}
break;
case "take-boat":
player.getDialogueInterpreter().open(((NPC) node).getId(), ((NPC) node));
break;
case "open":
switch (((GameObject) node).getId()) {
case 9565:
case 9563:
player.getPacketDispatch().sendMessage("The door is securely locked.");
break;
}
break;
case "pick-lock":
switch (((GameObject) node).getId()) {
case 9565:
if (player.getLocation().getY() <= 3187) {
player.getPacketDispatch().sendMessage("You simply cannot find a way to pick the lock from this side.");
return true;
}
break;
}
break;
case "talk-to":
player.lock(2);
((NPC) node).sendChat(MESSAGES[RandomFunction.random(MESSAGES.length)]);
GameWorld.submit(new Pulse(1) {
@Override
public boolean pulse() {
player.getDialogueInterpreter().sendDialogues(player, null, "Maybe I should let him sleep.");
return true;
}
});
break;
case "search":// banan box
if (player.getInventory().freeSlots() == 0) {
player.getPacketDispatch().sendMessage("Not enough inventory space.");
return true;
}
player.getPacketDispatch().sendMessage("There are lots of bananas in the crate.");
player.lock(2);
GameWorld.submit(new Pulse(1) {
@Override
public boolean pulse() {
if (player.getAttribute("wydin-rum", false)) {
if (player.getInventory().add(KARAMJAN_RUM)) {
player.removeAttribute("wydin-rum");
player.removeAttribute("stashed-rum");
player.animate(TAKE_ANIM);
player.getPacketDispatch().sendMessage("You find your bottle of rum in amongst the bananas.");
}
return true;
}
player.getDialogueInterpreter().open(9682749);
return true;
}
});
break;
}
return true;
}
@Override
public boolean isWalk(final Player player, final Node node) {
return !(node instanceof Item);
}
}

View file

@ -0,0 +1,150 @@
package plugin.interaction.city;
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.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.entity.player.link.diary.DiaryType;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.PluginManager;
/**
* Handles shilo village interactions.
* @author Vexia
*/
@InitializablePlugin
public final class ShiloVillagePlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.forId(511).getConfigurations().put("option:pay-fare", this);
NPCDefinition.forId(510).getConfigurations().put("option:pay-fare", this);
ObjectDefinition.forId(2230).getConfigurations().put("option:board", this);// cart
// travel.
ObjectDefinition.forId(2230).getConfigurations().put("option:pay-fare", this);// cart
// travel.
ObjectDefinition.forId(2265).getConfigurations().put("option:board", this);// cart
// travel.
ObjectDefinition.forId(2265).getConfigurations().put("option:pay-fare", this);// cart
// travel.
PluginManager.definePlugin(new VillageCartDialogue());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (node.getId()) {
case 511:
case 510:
player.getDialogueInterpreter().open(510, node);
break;
case 2230:
case 2265:
player.getDialogueInterpreter().open(510, RegionManager.getNpc(player, node.getId() == 2230 ? 510 : 511));
break;
}
return true;
}
/**
* Handles the vigroy dialogue.
* @author Vexia
*/
public static final class VillageCartDialogue extends DialoguePlugin {
/**
* If the ride is to shilo.
*/
private boolean shilo;
/**
* Constructs a new {@Code VigroyDialogue} {@Code Object}
* @param player the player.
*/
public VillageCartDialogue(Player player) {
super(player);
}
/**
* Constructs a new {@Code VigroyDialogue} {@Code Object}
*/
public VillageCartDialogue() {
/**
* empty.
*/
}
@Override
public DialoguePlugin newInstance(Player player) {
return new VillageCartDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
shilo = npc.getId() == 510;
npc("Hello Bwana!");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
npc("I am offering a cart ride to " + (shilo ? "Shilo Village" : "Brimhaven") + " if you're", "interested? It will cost 10 gold coins. Is that Ok?");
stage++;
break;
case 1:
player("Yes please, I'd like to go to " + (shilo ? "Shilo Village" : "Brimhaven") + ".");
stage++;
break;
case 2:
npc("Great! Just hop into the cart then and we'll go!");
stage++;
break;
case 3:
if (!player.getInventory().contains(995, 10)) {
player.sendMessage("Not enough coins.");
end();
break;
}
interpreter.sendDialogue("You hop into the cart and the driver urges the horses on. You take", "a taxing journey through the jungle to " + (shilo ? "Shilo Village" : "Brimhaven") + ".");
stage++;
break;
case 4:
interpreter.sendDialogue("You pay the fare and hand 10 gold coins to " + npc.getName() + ".");
stage++;
break;
case 5:
if (player.getInventory().remove(new Item(995, 10))) {
interpreter.sendDialogue("You feel tired from the journey, but at least you didn't have to walk", "all that distance.");
stage++;
} else {
end();
}
break;
case 6:
if (!player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).isComplete(1, 3)) {
player.getAchievementDiaryManager().getDiary(DiaryType.KARAMJA).updateTask(player, 1, 3, true);
}
end();
player.getProperties().setTeleportLocation(shilo ? Location.create(2834, 2951, 0) : Location.create(2780, 3212, 0));
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 511, 510 };
}
}
}

View file

@ -0,0 +1,71 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.DoorActionHandler;
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.object.GameObject;
import org.crandor.game.node.object.ObjectBuilder;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionManager;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used for taverly dungeon.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class TaverlyDungeonPlugin extends OptionHandler {
/**
* The suits of armour.
*/
private static final NPC[] ARMOUR_SUITS = new NPC[2];
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(2143).getConfigurations().put("option:open", this);
ObjectDefinition.forId(2144).getConfigurations().put("option:open", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final int id = ((GameObject) node).getId();
switch (id) {
case 2143:
case 2144:
if (player.getLocation().getX() < node.getLocation().getX() && !player.getAttribute("spawned_suits", false)) {
boolean alive = true;
for (int i = 0; i < ARMOUR_SUITS.length; i++) {
NPC npc = ARMOUR_SUITS[i];
if (npc == null || !npc.isActive()) {
Location location = Location.create(2887, 9829 + (i * 3), 0);
ARMOUR_SUITS[i] = npc = NPC.create(453, location);
npc.init();
npc.getProperties().getCombatPulse().attack(player);
GameObject object = RegionManager.getObject(location);
if (object != null) {
ObjectBuilder.remove(object);
}
alive = false;
}
}
if (!alive) {
player.setAttribute("spawned_suits", true);
player.getPacketDispatch().sendMessage("Suddenly the suit of armour comes to life!");
return true;
}
}
player.removeAttribute("spawned_suits");
DoorActionHandler.handleAutowalkDoor(player, (GameObject) node);
return true;
}
return false;
}
}

View file

@ -0,0 +1,880 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.NPCDefinition;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.component.Component;
import org.crandor.game.content.activity.ActivityManager;
import org.crandor.game.content.activity.ActivityPlugin;
import org.crandor.game.content.activity.CutscenePlugin;
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.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.impl.ForceMovement;
import org.crandor.game.node.entity.npc.AbstractNPC;
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.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.zone.MapZone;
import org.crandor.game.world.map.zone.ZoneBorders;
import org.crandor.game.world.map.zone.ZoneBuilder;
import org.crandor.game.world.repository.Repository;
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.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.PluginManager;
/**
* Represents the plugin used to handle all trollheim node interations.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class TrollheimPlugin extends OptionHandler {
/**
* Represents the locations to use.
*/
private static final Location[] LOCATIONS = new Location[] { new Location(2269, 4752, 0), new Location(2858, 3577, 0), Location.create(2808, 10002, 0), Location.create(2796, 3615, 0), Location.create(2907, 10019, 0), Location.create(2904, 3643, 0), new Location(2908, 3654, 0), Location.create(2907, 10035, 0), new Location(2893, 10074, 0), new Location(2893, 3671, 0) };
/**
* Represents the climbing boots item.
*/
private static final Item CLIMBING_BOOTS = new Item(3105);
/**
* Represents the climb down animation.
*/
private static final Animation CLIMB_DOWN = new Animation(1148);
/**
* Represents the climb up animation.
*/
private static final Animation CLIMB_UP = new Animation(740);
/**
* Represents the climb fail animation.
*/
public static final Animation CLIMB_FAIL = new Animation(739);
/**
* Represents the low jumpa nimation.
*/
private static final Animation JUMP = new Animation(839);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(3735).getConfigurations().put("option:enter", this);
ObjectDefinition.forId(32738).getConfigurations().put("option:exit", this);
NPCDefinition.forId(1069).getConfigurations().put("option:talk-to", this);
ObjectDefinition.forId(3742).getConfigurations().put("option:read", this);
ObjectDefinition.forId(3774).getConfigurations().put("option:leave", this);
ObjectDefinition.forId(3723).getConfigurations().put("option:climb", this);// located
// in
// circle
// area.
ObjectDefinition.forId(3722).getConfigurations().put("option:climb", this);// located
// in
// circle
// area.
ObjectDefinition.forId(3748).getConfigurations().put("option:climb", this);
ObjectDefinition.forId(3790).getConfigurations().put("option:climb", this);// pos=Location.create(2858,
// 3627,
// 0)
ObjectDefinition.forId(3791).getConfigurations().put("option:climb", this);// pos=Location.create(2858,
// 3627,
// 0)
ObjectDefinition.forId(3782).getConfigurations().put("option:open", this);// arena
// entrance
ObjectDefinition.forId(3783).getConfigurations().put("option:open", this);// arena
// entrance
ObjectDefinition.forId(3762).getConfigurations().put("option:open", this);// secret
// door.
ObjectDefinition.forId(4499).getConfigurations().put("option:enter", this);// entrance
// near
// golden
// apple.
ObjectDefinition.forId(4500).getConfigurations().put("option:enter", this);// entrance
// near
// golden
// apple.
ObjectDefinition.forId(9303).getConfigurations().put("option:climb", this);// lvl
// 41.
ObjectDefinition.forId(3782).getConfigurations().put("option:open", this);// arena
// entrance.
ObjectDefinition.forId(3783).getConfigurations().put("option:open", this);// arena
// entrance.
ObjectDefinition.forId(3785).getConfigurations().put("option:open", this);// arena
// exit.
ObjectDefinition.forId(3786).getConfigurations().put("option:open", this);// arena
// exit.
ObjectDefinition.forId(3757).getConfigurations().put("option:enter", this);// arena
// cave
// entrance.
ObjectDefinition.forId(3758).getConfigurations().put("option:exit", this);// arena
// cave
// exit.
ObjectDefinition.forId(9327).getConfigurations().put("option:climb", this);// lvl
// 64
ObjectDefinition.forId(9304).getConfigurations().put("option:climb", this);
;// lvl
// 43
ObjectDefinition.forId(3803).getConfigurations().put("option:climb", this);
;// lvl
// 43
// near
// trollheim
// top.
ObjectDefinition.forId(3804).getConfigurations().put("option:climb", this);
;// lvl
// 43
// near
// trollheim
// top.
ObjectDefinition.forId(9306).getConfigurations().put("option:climb", this);// lvl
// 47
ObjectDefinition.forId(9305).getConfigurations().put("option:climb", this);// lvl
// 44
ObjectDefinition.forId(3759).getConfigurations().put("option:enter", this);// top
// cave.
ObjectDefinition.forId(3771).getConfigurations().put("option:enter", this);// stronghold
// to
// herb
// patch
ObjectDefinition.forId(18834).getConfigurations().put("option:climb-up", this);// stronghold
// ladder
ObjectDefinition.forId(18833).getConfigurations().put("option:climb-down", this);// stronghold
// ladder
PluginManager.definePlugin(new SabaDialogue());
PluginManager.definePlugin(new WoundedSoldier());
PluginManager.definePlugin(new WarningZone());
ActivityManager.register(new WarningCutscene());
PluginManager.definePlugin(new TenzingDialogue());
PluginManager.definePlugin(new TrollNPC());
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
final int id = node instanceof GameObject ? ((GameObject) node).getId() : ((NPC) node).getId();
final Location loc = node.getLocation();
int xOffset = 0, yOffset = 0;
Direction direction = Direction.SOUTH;
switch (option) {
case "enter":
switch (id) {
case 3735:
player.getProperties().setTeleportLocation(LOCATIONS[0]);
break;
case 4499:
player.getProperties().setTeleportLocation(LOCATIONS[2]);
break;
case 4500:
player.getProperties().setTeleportLocation(LOCATIONS[3]);
break;
case 3723:
player.getProperties().setTeleportLocation(LOCATIONS[4]);
break;
case 3757:
player.getProperties().setTeleportLocation(loc.equals(new Location(2907, 3652, 0)) ? LOCATIONS[7] : LOCATIONS[4]);
break;
case 3759:
player.getProperties().setTeleportLocation(LOCATIONS[8]);
break;
case 3771:
player.teleport(new Location(2837, 10090, 2));
break;
}
break;
case "leave":
player.teleport(new Location(2840, 3690));
break;
case "exit":
switch (id) {
case 32738:
if (loc.equals(new Location(2892, 10072, 0))) {
player.getProperties().setTeleportLocation(LOCATIONS[0]);
return true;
}
player.teleport(LOCATIONS[1]);
break;
case 3758:
player.getProperties().setTeleportLocation(loc.equals(new Location(2906, 10036, 0)) ? LOCATIONS[6] : LOCATIONS[5]);
break;
}
break;
case "talk-to":
switch (id) {
case 1069:
player.getDialogueInterpreter().open(id, node);
break;
}
break;
case "read":
switch (id) {
case 3742:
ActivityManager.start(player, "trollheim-warning", false);
break;
}
break;
case "open":
switch (id) {
case 3785:// exit
case 3786:// exit
case 3782:// entrance
case 3783:// entrance.
DoorActionHandler.handleAutowalkDoor(player, (GameObject) node);
return true;
case 3672:
player.getPacketDispatch().sendMessage("You don't know how to open the secret door.");
break;
}
break;
case "climb-up":
switch (id) {
case 18834:
ClimbActionHandler.climb(player, ClimbActionHandler.CLIMB_UP, new Location(2828, 3678), "You climb up the ladder to the surface.");
break;
}
break;
case "climb-down":
switch (id) {
case 18833:
ClimbActionHandler.climb(player, ClimbActionHandler.CLIMB_DOWN, new Location(2831, 10076, 2), "You climb down the ladder.");
break;
}
break;
case "climb":
if (!player.getEquipment().containsItem(CLIMBING_BOOTS)) {
player.getPacketDispatch().sendMessage("You need Climbing boots to negotiate these rocks.");
return true;
}
final GameObject object = ((GameObject) node);
switch (id) {
case 3723:
ForceMovement.run(player, player.getLocation(), object.getLocation().transform(0, 2, 0), CLIMB_UP);
break;
case 3722:
ForceMovement.run(player, player.getLocation(), object.getLocation().transform(0, -3, 0), CLIMB_DOWN, CLIMB_DOWN, object.getDirection());
break;
case 3790:// rock scalling.
xOffset = player.getLocation().getX() < loc.getX() ? 2 : -2;
direction = getOpposite(ForceMovement.direction(player.getLocation(), object.getLocation().transform(xOffset, yOffset, 0)));
ForceMovement.run(player, player.getLocation(), object.getLocation().transform(xOffset, yOffset, 0), CLIMB_DOWN, CLIMB_DOWN, direction);
break;
case 3791:// rock scalling.
xOffset = player.getLocation().getX() < loc.getX() ? 2 : -2;
ForceMovement.run(player, player.getLocation(), object.getLocation().transform(xOffset, yOffset, 0), CLIMB_UP);
break;
case 3748:
player.getPacketDispatch().sendMessage("You climb onto the rock...");
if (loc.equals(new Location(2821, 3635, 0))) {
ForceMovement.run(player, player.getLocation(), loc.transform(player.getLocation().getX() > loc.getX() ? -1 : 1, 0, 0), JUMP);
} else if (loc.equals(new Location(2910, 3687, 0)) || loc.equals(new Location(2910, 3686, 0))) {
if (player.getSkills().getLevel(Skills.AGILITY) < 43) {
player.getPacketDispatch().sendMessage("You need an Agility level of 43 in order to climb this mountain side.");
return true;
}
if (player.getLocation().equals(Location.create(2911, 3687, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2909, 3687, 0), JUMP);
} else if (player.getLocation().equals(new Location(2909, 3687, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2911, 3687, 0), JUMP);
} else if (player.getLocation().equals(Location.create(2911, 3686, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2909, 3686, 0), JUMP);
} else {
ForceMovement.run(player, player.getLocation(), Location.create(2911, 3686, 0), JUMP);
}
} else {
ForceMovement.run(player, player.getLocation(), player.getLocation().getY() < object.getLocation().getY() ? player.getLocation().transform(0, 2, 0) : player.getLocation().transform(0, -2, 0), JUMP);
}
player.getPacketDispatch().sendMessage("...and step down the other side.");
break;
case 3803:
case 3804:
if (player.getSkills().getLevel(Skills.AGILITY) < 43) {
player.getPacketDispatch().sendMessage("You need an Agility level of 43 in order to climb this mountain side.");
return true;
}
if (player.getLocation().equals(Location.create(2884, 3684, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2886, 3684, 0), CLIMB_UP);
} else if (player.getLocation().equals(Location.create(2884, 3683, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2886, 3683, 0), CLIMB_UP);
} else if (player.getLocation().equals(Location.create(2886, 3683, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2884, 3683, 0), CLIMB_DOWN, CLIMB_DOWN, Direction.EAST);
} else if (player.getLocation().equals(Location.create(2888, 3660, 0)) || player.getLocation().equals(Location.create(2887, 3660, 0))) {
ForceMovement.run(player, player.getLocation(), player.getLocation().transform(0, 2, 0), CLIMB_UP);
} else if (player.getLocation().equals(Location.create(2888, 3662, 0)) || player.getLocation().equals(Location.create(2887, 3662, 0))) {
ForceMovement.run(player, player.getLocation(), player.getLocation().transform(0, -2, 0), CLIMB_DOWN, CLIMB_DOWN, Direction.NORTH);
} else {
ForceMovement.run(player, player.getLocation(), Location.create(2884, 3684, 0), CLIMB_DOWN, CLIMB_DOWN, Direction.EAST);
}
break;
case 9306:
if (player.getSkills().getLevel(Skills.AGILITY) < 47) {
player.getPacketDispatch().sendMessage("You need an Agility level of 47 in order to climb this mountain side.");
return true;
}
if (player.getLocation().equals(Location.create(2903, 3680, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2900, 3680, 0), CLIMB_UP);
} else {
ForceMovement.run(player, player.getLocation(), Location.create(2903, 3680, 0), CLIMB_DOWN, CLIMB_DOWN, Direction.WEST);
}
break;
case 9303:
if (player.getSkills().getLevel(Skills.AGILITY) < 41) {
player.getPacketDispatch().sendMessage("You need an Agility level of 41 in order to climb this mountain side.");
return true;
}
if (player.getLocation().getX() > loc.getX()) {
ForceMovement.run(player, player.getLocation(), object.getLocation().transform(-2, 0, 0), CLIMB_DOWN, CLIMB_DOWN, Direction.EAST);
} else {
ForceMovement.run(player, player.getLocation(), object.getLocation().transform(2, 0, 0), CLIMB_UP);
}
break;
case 9304:
if (player.getSkills().getLevel(Skills.AGILITY) < 47) {
player.getPacketDispatch().sendMessage("You need an Agility level of 47 in order to climb this mountain side.");
return true;
}
if (player.getLocation().equals(Location.create(2878, 3665, 0))) {
ForceMovement.run(player, player.getLocation(), new Location(2878, 3668, 0), CLIMB_UP);
} else {
ForceMovement.run(player, player.getLocation(), new Location(2878, 3665, 0), CLIMB_DOWN, CLIMB_DOWN, Direction.NORTH);
}
break;
case 9305:
if (player.getSkills().getLevel(Skills.AGILITY) < 44) {
player.getPacketDispatch().sendMessage("You need an Agility level of 44 in order to climb this mountain side.");
return true;
}
if (player.getLocation().equals(new Location(2909, 3684, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2907, 3682, 0), CLIMB_UP, CLIMB_UP, Direction.SOUTH);
} else {
ForceMovement.run(player, player.getLocation(), Location.create(2909, 3684, 0), CLIMB_DOWN, CLIMB_DOWN, Direction.SOUTH);
}
break;
case 9327:
if (player.getSkills().getLevel(Skills.AGILITY) < 64) {
player.getPacketDispatch().sendMessage("You need an Agility level of 64 in order to climb this mountain side.");
return true;
}
if (object.getLocation().equals(new Location(2916, 3672, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2918, 3672, 0), CLIMB_UP);
} else if (object.getLocation().equals(new Location(2917, 3672, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2915, 3672, 0), CLIMB_DOWN, CLIMB_DOWN, Direction.EAST);
} else if (object.getLocation().equals(new Location(2923, 3673, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2921, 3672, 0), CLIMB_UP);
} else if (object.getLocation().equals(new Location(2922, 3672, 0))) {
ForceMovement.run(player, player.getLocation(), Location.create(2924, 3673, 0), CLIMB_DOWN, CLIMB_DOWN, Direction.WEST);
}
break;
}
break;
}
return true;
}
@Override
public Location getDestination(Node node, Node n) {
if (n instanceof GameObject) {
final GameObject object = ((GameObject) n);
if (object.getId() == 3782) {
if (node.getLocation().getX() >= 2897) {
return Location.create(2897, 3618, 0);
}
} else if (object.getId() == 3804) {
if (object.getLocation().equals(new Location(2885, 3684, 0)) && node.getLocation().getX() >= 2885) {
return object.getLocation().transform(1, 0, 0);
}
} else if (object.getId() == 9306 && node.getLocation().getX() >= 2902) {
return Location.create(2903, 3680, 0);
}
}
return null;
}
/**
* Gets the opposite direction.
* @param dir the dir.
* @return the opposite direction.
*/
private Direction getOpposite(Direction dir) {
switch (dir) {
case EAST:
return Direction.WEST;
case NORTH:
return Direction.SOUTH;
case SOUTH:
return Direction.NORTH;
case WEST:
return Direction.EAST;
default:
break;
}
return null;
}
/**
* Represents the saba dialogue plugin.
* @author 'Vexia
* @version 1.0
*/
public final class SabaDialogue extends DialoguePlugin {
/**
* Constructs a new {@code TrolleimPlugin} {@code Object}.
*/
public SabaDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code TrolleimPlugin} {@code Object}.
* @param player the player.
*/
public SabaDialogue(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new SabaDialogue(player);
}
@Override
public boolean open(Object... args) {
player("Hello!");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
npc("Why won't people leave me alone?!");
stage = 1;
break;
case 1:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 1070 };
}
}
/**
* Represents the wounded soldiers dialogue plugin.
* @author 'Vexia
* @version 1.0
*/
public final class WoundedSoldier extends DialoguePlugin {
/**
* Constructs a new {@code WoundedSoldier} {@code Object}.
*/
public WoundedSoldier() {
/**
* empty.
*/
}
/**
* Constructs a new {@code TrolleimPlugin} {@code Object}.
* @param player the player.
*/
public WoundedSoldier(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new WoundedSoldier(player);
}
@Override
public boolean open(Object... args) {
player("Are you OK?");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
npc("Urrrgggh.....");
stage = 1;
break;
case 1:
npc("I'll be OK, the trolls only leave the plateau at nightfall.", "The guys are bringing a stretcher shortly.");
stage = 2;
break;
case 2:
player("As long as you're sure.");
stage = 3;
break;
case 3:
npc("It's my own fault really, I was having a walk and", "wandered past the danger sign. The trolls throw rocks", "down at any one who goes up the path!");
stage = 4;
break;
case 4:
npc("Don't go up there!");
stage = 5;
break;
case 5:
player("OK, thanks for the warning.");
stage = 6;
break;
case 6:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 1069 };
}
}
/**
* Represents the warning map zone.
* @author 'Vexia
* @version 1.0
*/
public static final class WarningZone extends MapZone implements Plugin<Object> {
/**
* Represents the warning component interface,
*/
private static final Component COMPONENT = new Component(581);
/**
* Constructs a new {@code WarningZone} {@code Object}.
*/
public WarningZone() {
super("trollheim-warning", true);
}
@Override
public boolean enter(final Entity entity) {
if (entity instanceof Player) {
final Player p = (Player) entity;
if (p.getWalkingQueue().getFootPrint().getY() < 3592) {
p.getWalkingQueue().reset();
p.getPulseManager().clear();
p.getInterfaceManager().open(COMPONENT);
}
}
return super.enter(entity);
}
@Override
public void configure() {
register(new ZoneBorders(2837, 3592, 2838, 3593));
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ZoneBuilder.configure(this);
return this;
}
@Override
public Object fireEvent(String identifier, Object... args) {
return null;
}
}
/**
* Represents the warning cutscene plugin.
* @author 'Vexia
* @version 1.0
*/
public static final class WarningCutscene extends CutscenePlugin {
/**
* Represents the throwing animation.
*/
private static final Animation THROW = new Animation(1142);
/**
* Represents the troll location.
*/
private static final Location TROLL_LOCATION = new Location(2851, 3598, 0);
/**
* Constructs a new {@code WarningCutscene} {@code Object}.
*/
public WarningCutscene() {
super("trollheim-warning");
}
/**
* Constructs a new {@code WarningCutscene} {@code Object}.
* @param p the player.
*/
public WarningCutscene(Player p) {
super("trollheim-warning", false);
this.player = p;
}
@Override
public ActivityPlugin newInstance(Player p) throws Throwable {
return new WarningCutscene(p);
}
@Override
public void open() {
final NPC npc = Repository.findNPC(TROLL_LOCATION);
Location loc = Location.create(2849, 3597, 0);
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.POSITION, loc.getX() - 2, loc.getY(), 1300, 1, 30));
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.ROTATION, loc.getX() + 22, loc.getY() + 10, 1300, 1, 30));
GameWorld.submit(new Pulse(1, player) {
int count = 0;
@Override
public boolean pulse() {
switch (count++) {
case 4:
if (npc != null) {
npc.faceTemporary(player, 3);
npc.animate(THROW);
}
break;
case 6:
WarningCutscene.this.stop(false);
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.RESET, 0, 0, 1300, 1, 30));
return true;
}
return false;
}
});
}
@Override
public int getMapState() {
return 0;
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
ActivityManager.register(this);
}
}
/**
* Represents the dialogue plugin used for the tenzing npc.
* @author 'Vexia
* @version 1.0
*/
public static final class TenzingDialogue extends DialoguePlugin {
/**
* Represents the coins items.
*/
private static final Item COINS = new Item(995, 12);
/**
* Constructs a new {@code TenzingDialogue} {@code Object}.
*/
public TenzingDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code TenzingDialogue} {@code Object}.
* @param player the player.
*/
public TenzingDialogue(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new TenzingDialogue(player);
}
@Override
public boolean open(Object... args) {
player("Hello Tenzing!");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
npc("Hello traveller. What can I do for you?");
stage = 1;
break;
case 1:
options("Can I buy some Climbing boots?", "What does a Sherpa do?", "How did you find out about the secret way?", "Nice place you have here.", "Nothing, thanks!");
stage = 2;
break;
case 2:
switch (buttonId) {
case 1:
player("Can I buy some Climbing boots?");
stage = 10;
break;
case 2:
player("What does a Sherpa do?");
stage = 20;
break;
case 3:
player("How did you find out about the secret way?");
stage = 30;
break;
case 4:
player("Nice place you have here.");
stage = 40;
break;
case 5:
player("Nothing, thanks!");
stage = 50;
break;
}
break;
case 10:
npc("Sure, I'll sell you some in your size for 12 gold.");
stage = 11;
break;
case 11:
options("OK, sounds good.", "No, thanks.");
stage = 12;
break;
case 12:
switch (buttonId) {
case 1:
player("OK, sounds good.");
stage = 13;
break;
case 2:
player("No, thanks.");
stage = 50;
break;
}
break;
case 13:
if (!player.getInventory().hasSpaceFor(CLIMBING_BOOTS)) {
player("I don't have enough space in my backback right", "this second.");
stage = 50;
return true;
}
if (!player.getInventory().containsItem(COINS)) {
end();
return true;
}
if (!player.getInventory().remove(COINS)) {
player("I don't have enough coins right now.");
stage = 50;
return true;
}
if (player.getInventory().add(CLIMBING_BOOTS)) {
interpreter.sendItemMessage(CLIMBING_BOOTS, "Tenzing has given you some Climbing boots.");
player.getPacketDispatch().sendMessage("Tenzing has given you some Climbing boots.");
}
stage = 50;
break;
case 20:
npc("We are expert guides that take adventurers such as", "yourself, on mountaineering expeditions.");
stage = 21;
break;
case 21:
end();
break;
case 30:
npc("I used to take adventurers up Death Plateau and", "further north before the trolls came. I know these", "mountains well.");
stage = 31;
break;
case 31:
end();
break;
case 40:
npc("Thanks, I built it myself! I'm usually self sufficient but", "I can't earn any money with the trolls camped on", "Death Plateau,");
stage = 41;
break;
case 41:
end();
break;
case 50:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 1071 };
}
}
/**
* Represents the a trollheim troll.
* @author 'Vexia
* @version 1.0
*/
public final class TrollNPC extends AbstractNPC {
/**
* Constructs a new {@code TrollNPC} {@code Object}.
*/
public TrollNPC() {
super(0, null);
}
/**
* Constructs a new {@code TrollNPC} {@code Object}.
* @param id the id.
* @param location the location.
*/
public TrollNPC(int id, Location location) {
super(id, location, true);
this.setAggressive(true);
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return new TrollNPC(id, location);
}
@Override
public int[] getIds() {
return new int[] { 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1138 };
}
}
}

View file

@ -0,0 +1,198 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.activity.ActivityManager;
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.npc.NPC;
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.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used for tzhaar city.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class TzhaarCityPlugin extends OptionHandler {
/**
* Represents the locations to use.
*/
private static final Location[] LOCATIONS = new Location[] { Location.create(2480, 5175, 0), Location.create(2866, 9571, 0) };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(31284).getConfigurations().put("option:enter", this);// karamja
// cave.
ObjectDefinition.forId(9359).getConfigurations().put("option:enter", this);// tzhaar
// exit
ObjectDefinition.forId(9356).getConfigurations().put("option:enter", this);
ObjectDefinition.forId(9369).getConfigurations().put("option:pass", this);
new TzhaarDialogue().init();
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
int id = ((GameObject) node).getId();
switch (option) {
case "enter":
switch (id) {
case 31284:
player.getProperties().setTeleportLocation(LOCATIONS[0]);
break;
case 9359:
player.getProperties().setTeleportLocation(LOCATIONS[1]);
break;
case 9356:
if (player.getFamiliarManager().hasFamiliar()) {
player.getPacketDispatch().sendMessage("You can't enter this with a follower.");
break;
}
ActivityManager.start(player, "fight caves", false);
break;
}
break;
case "pass":
switch (id) {
case 9369:
ActivityManager.start(player, "fight pits", false);
break;
}
break;
}
return true;
}
/**
* Represents the dialogue plugin used for the tzhaar npcs.
* @author 'Vexia
* @version 1.0
*/
public static final class TzhaarDialogue extends DialoguePlugin {
/**
* Constructs a new {@code TzhaarDialogue} {@code Object}.
*/
public TzhaarDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code TzhaarDialogue} {@code Object}.
* @param player the player.
*/
public TzhaarDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new TzhaarDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
npc("Can I help you JalYt-Ket-" + player.getUsername() + "?");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
options("What do you have to trade?", "What did you call me?", "No I'm fine thanks.");
stage = 1;
break;
case 1:
switch (buttonId) {
case 1:
end();
npc.openShop(player);
break;
case 2:
player("What did you call me?");
stage = 20;
break;
case 3:
player("No I'm fine thanks.");
stage = 30;
break;
}
break;
case 10:
break;
case 20:
npc("Are you not JalYt-Ket?");
stage = 21;
break;
case 21:
options("What's a 'JalYt-Ket'?", "I guess so...", "No I'm not!");
stage = 22;
break;
case 22:
switch (buttonId) {
case 1:
player("What's a 'JalYt-Ket'?");
stage = 100;
break;
case 2:
player("I guess so...");
stage = 120;
break;
case 3:
player("No I'm not!");
stage = 130;
break;
}
break;
case 100:
npc("That what you are... you tough and strong no?");
stage = 101;
break;
case 101:
player("Well yes I suppose I am...");
stage = 102;
break;
case 102:
npc("Then you JalYt-Ket!");
stage = 103;
break;
case 103:
end();
break;
case 120:
npc("Well then, no problems.");
stage = 121;
break;
case 121:
end();
break;
case 130:
end();
break;
case 23:
end();
break;
case 30:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 2620, 2622, 2623 };
}
}
}

View file

@ -0,0 +1,296 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.component.Component;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.dialogue.FacialExpression;
import org.crandor.game.content.global.action.ClimbActionHandler;
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.map.Location;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle node interactions in varrock.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class VarrockNodePlugin extends OptionHandler {
/**
* Represents the bronze axe item.
*/
private static final Item BRONZE_AXE = new Item(1351);
/**
* Represents the spade item.
*/
private static final Item SPADE = new Item(952);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(24357).getConfigurations().put("option:climb-up", this);
ObjectDefinition.forId(5581).getConfigurations().put("option:take-axe", this);
ObjectDefinition.forId(36974).getConfigurations().put("option:take-axe", this);
ObjectDefinition.forId(24428).getConfigurations().put("option:walk-down", this);
ObjectDefinition.forId(1749).getConfigurations().put("option:climb-down", this);
ObjectDefinition.forId(23636).getConfigurations().put("option:read", this);
ObjectDefinition.forId(28094).getConfigurations().put("option:open", this);
ObjectDefinition.forId(24389).getConfigurations().put("option:knock-at", this);
ObjectDefinition.forId(9662).getConfigurations().put("option:take", this);
ObjectDefinition.forId(17974).getConfigurations().put("option:climb-up", this);
ObjectDefinition.forId(29534).getConfigurations().put("option:enter", this);
ObjectDefinition.forId(17985).getConfigurations().put("option:climb-down", this);
ObjectDefinition.forId(24366).getConfigurations().put("option:climb-up", this);
ObjectBuilder.add(new GameObject(17974, new Location(3204, 9911), 10, 0));
new KnockatDoorDialogue().init();
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
final int id = node instanceof GameObject ? ((GameObject) node).getId() : ((Item) node).getId();
switch (id) {
case 24366:
ClimbActionHandler.climb(player, ClimbActionHandler.CLIMB_UP, new Location(3237, 3459));
return true;
case 29534:
player.getDialogueInterpreter().open(543543);
return true;
case 17985:
ClimbActionHandler.climb(player, ClimbActionHandler.CLIMB_DOWN, new Location(3204, 9910), "You enter the murky sewers.");
return true;
case 17974:
ClimbActionHandler.climb(player, ClimbActionHandler.CLIMB_UP, new Location(3179, 3472), "You resurface.");
return true;
case 24389:
player.getDialogueInterpreter().open(KnockatDoorDialogue.ID, player.getLocation().getX() == 3182 ? 45 : 44);
break;
case 28094:
player.getDialogueInterpreter().sendDialogues(player, FacialExpression.ANNOYED, "I don't think I should go inside.");
break;
case 23636:
player.getInterfaceManager().open(new Component(531));
break;
case 1749:
if (player.getLocation().getZ() == 2 && player.getLocation().getDistance(new Location(3096, 3433, 2)) < 4) {
ClimbActionHandler.climb(player, new Animation(827), Location.create(3097, 3432, 1));
return true;
} else if (player.getLocation().getZ() == 1 && player.getLocation().getDistance(new Location(3095, 3433, 1)) < 4) {
ClimbActionHandler.climb(player, new Animation(827), Location.create(3096, 3432, 0));
return true;
}
ClimbActionHandler.climbLadder(player, (GameObject) node, option);
return true;
case 5581:
case 36974:
if (!player.getInventory().add(BRONZE_AXE)) {
player.getPacketDispatch().sendMessage("You don't have enough inventory space.");
return true;
}
ObjectBuilder.replace(((GameObject) node), ((GameObject) node).transform(5582), 5000);
break;
case 24357:
if (player.getLocation().getDistance(Location.create(3188, 3358, 0)) < 3) {
ClimbActionHandler.climb(player, new Animation(828), Location.create(3188, 3354, 1));
return true;
}
if (((GameObject) node).getLocation().equals(new Location(3156, 3435, 0))) {
ClimbActionHandler.climb(player, new Animation(828), Location.create(3155, 3435, 1));
return true;
}
ClimbActionHandler.climbLadder(player, (GameObject) node, option);
return true;
case 24428:
// TODO:
return false;
case 9662:
if (!player.getInventory().hasSpaceFor(SPADE)) {
player.getPacketDispatch().sendMessage("Not enough inventory space.");
return true;
}
player.getInventory().add(SPADE);
ObjectBuilder.replace((GameObject) node, ((GameObject) node).transform(0), 250);
return true;
}
return true;
}
@Override
public boolean isWalk() {
return false;
}
@Override
public boolean isWalk(final Player player, final Node node) {
return !(node instanceof Item);
}
/**
* Represents the dialogue used for the knocking at a door in varrock bank.
* @author 'Vexia
* @version 1.0
*/
public final class KnockatDoorDialogue extends DialoguePlugin {
/**
* Represents the id of this dialogue.
*/
private static final int ID = 903042893;
/**
* Represents the id to use.
*/
private int npcId;
/**
* Constructs a new {@code KnockatDoorDialogue} {@code Object}.
*/
public KnockatDoorDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code KnockatDoorDialogue} {@code Object}.
* @param player the player.
*/
public KnockatDoorDialogue(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new KnockatDoorDialogue(player);
}
@Override
public boolean open(Object... args) {
npcId = (int) args[0];
player("I don't think I'm ever going to be allowed in there.");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
player.lock(3);
interpreter.sendPlainMessage(true, "<col=08088A>Knock knock...");
GameWorld.submit(new Pulse(3, player) {
@Override
public boolean pulse() {
interpreter.sendDialogues(npcId, null, "Who's there?");
stage = 1;
return true;
}
});
break;
case 1:
options("I'm " + player.getUsername() + ". Please let me in.", "Boo.", "Kanga.", "Thank.", "Doctor.");
stage = 2;
break;
case 2:
switch (buttonId) {
case 1:
player("I'm " + player.getUsername() + ". Please let me in.");
stage = 10;
break;
case 2:
player("Boo.");
stage = 20;
break;
case 3:
player("Kanga.");
stage = 30;
break;
case 4:
player("Thank.");
stage = 40;
break;
case 5:
player("Doctor.");
stage = 50;
break;
}
break;
case 10:
interpreter.sendDialogues(npcId, null, "No. Staff only beyond this point.", "You can't come in here.");
stage = 11;
break;
case 11:
end();
break;
case 20:
interpreter.sendDialogues(npcId, null, "Boo who?");
stage = 21;
break;
case 21:
player("There's no need to cry!");
stage = 22;
break;
case 22:
interpreter.sendDialogues(npcId, FacialExpression.ANGRY, "What? I'm not... oh, just go away!");
stage = 23;
break;
case 23:
end();
break;
case 30:
interpreter.sendDialogues(npcId, null, "Kanga who?");
stage = 31;
break;
case 31:
player("No, 'kangaroo'.");
stage = 32;
break;
case 32:
interpreter.sendDialogues(npcId, FacialExpression.ANGRY, "Stop messing about and go away!");
stage = 33;
break;
case 33:
end();
break;
case 40:
interpreter.sendDialogues(npcId, null, "Thank who?");
stage = 41;
break;
case 41:
player("You're welcome!");
stage = 42;
break;
case 42:
interpreter.sendDialogues(npcId, FacialExpression.ANGRY, "Stop it!");
stage = 43;
break;
case 43:
end();
break;
case 50:
interpreter.sendDialogues(npcId, FacialExpression.ANGRY, "Doctor. wh.. hang on, I'm not falling for that one again!", "Go away.");
stage = 51;
break;
case 51:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 903042893 };
}
}
}

View file

@ -0,0 +1,145 @@
package plugin.interaction.city;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.content.global.action.ClimbActionHandler;
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.TeleportManager.TeleportType;
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;
/**
* Represents a plugin used to handle wilderness nodes.
*
* @author 'Vexia
* @author Splinter
* @version 1.0
*/
@InitializablePlugin
public final class WildernessPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
new KBDPlugin().newInstance(arg);
ObjectDefinition.forId(37749).getConfigurations().put("option:go-through", this);
ObjectDefinition.forId(37928).getConfigurations().put("option:go-through", this);
ObjectDefinition.forId(37929).getConfigurations().put("option:go-through", this);
ObjectDefinition.forId(38811).getConfigurations().put("option:go-through", this);
ObjectDefinition.forId(39191).getConfigurations().put("option:climb-up", this);
ObjectDefinition.forId(39188).getConfigurations().put("option:open", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (node.getId()) {
case 37749:
player.teleport(Location.create(2885, 4372, 2));
break;
case 39191:
ClimbActionHandler.climb(player, ClimbActionHandler.CLIMB_UP, Location.create(3239, 3606, 0), "You climb up the ladder to the surface.");
break;
case 39188:
ClimbActionHandler.climb(player, ClimbActionHandler.CLIMB_DOWN, Location.create(3241, 9991, 0), "You descend into the cavern below.");
break;
case 37928:
player.teleport(Location.create(3214, 3782, 0));
break;
case 38811:
case 37929:
player.teleport(player.getLocation().transform(player.getLocation().getX() < node.getLocation().getX() ? 4 : -4, 0, 0));
break;
}
return true;
}
/**
* Represents the plugin used to handle kbd nodes.
*
* @author 'Vexia
* @version 1.0
*/
public static final class KBDPlugin extends OptionHandler {
/**
* Represents the locations used for kbd interactions.
*/
private static final Location[] LOCATIONS = new Location[] { new Location(3017, 3849, 0), Location.create(3069, 10257, 0), new Location(3069, 3856, 0), new Location(3017, 3850, 0), Location.create(2272, 4680, 0), Location.create(3067, 10253, 0), new Location(3069, 10256, 0) };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(1765).getConfigurations().put("option:climb-down", this);// ladder
ObjectDefinition.forId(1766).getConfigurations().put("option:climb-up", this);// ladder
ObjectDefinition.forId(1816).getConfigurations().put("option:pull", this);// kbd
ObjectDefinition.forId(1817).getConfigurations().put("option:pull", this);// kbd
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
int id = ((GameObject) node).getId();
switch (option) {
case "climb-down":
switch (id) {
case 1765:// kbd ladder.
if (node.getLocation().equals(LOCATIONS[0])) {
ClimbActionHandler.climb(player, new Animation(827), LOCATIONS[1]);
} else {
ClimbActionHandler.climbLadder(player, (GameObject) node, option);
return true;
}
break;
}
break;
case "climb-up":
switch (id) {
case 1766:// kbd leave ladder.
if (node.getLocation().equals(LOCATIONS[6])) {
ClimbActionHandler.climb(player, new Animation(828), LOCATIONS[3]);
} else {
ClimbActionHandler.climbLadder(player, (GameObject) node, option);
return true;
}
break;
}
break;
case "pull":
switch (id) {
case 1816:// kbd lever.
if (player.getLocation().withinDistance(LOCATIONS[5])) {
player.getPacketDispatch().sendMessage("You pull the lever...");
player.getTeleporter().send(LOCATIONS[4], TeleportType.NORMAL);
player.getPacketDispatch().sendMessage("... and teleport into the lair of the King Black Dragon!", 5);
}
break;
case 1817:
if (player.getLocation().withinDistance(LOCATIONS[4])) {
player.getPacketDispatch().sendMessage("You pull the lever...");
player.getTeleporter().send(LOCATIONS[5], TeleportType.NORMAL);
player.getPacketDispatch().sendMessage("... and teleport out of the lair of the King Black Dragon!", 5);
}
break;
}
break;
}
return true;
}
@Override
public Location getDestination(Node node, Node n) {
// if (n instanceof GameObject) {
// int id = ((GameObject) n).getId();
// if (id == 1817) {
// return Location.create(2273, 4680, 0);
// } else if (id == 1816) {
// return Location.create(3067, 10253, 0);
// }
// }
return null;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,189 @@
package plugin.interaction.city;
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.global.action.DoorActionHandler;
import org.crandor.game.content.skill.free.crafting.gem.Gems;
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.TeleportManager.TeleportType;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Location;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.PluginManager;
/**
* Handles the zanaris city plugin.
* @author Vexia
*/
@InitializablePlugin
public final class ZanarisPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
PluginManager.definePlugin(new MagicDoorDialogue());
ObjectDefinition.forId(12094).getConfigurations().put("option:use", this);
ObjectDefinition.forId(12045).getConfigurations().put("option:open", this);
ObjectDefinition.forId(12047).getConfigurations().put("option:open", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (node.getId()) {
case 12094:
player.getWalkingQueue().reset();
player.getWalkingQueue().addPath(2452, 4473);
player.getTeleporter().send(Location.create(3201, 3169, 0), TeleportType.FAIRY_RING);
break;
case 12045:
case 12047:
if ((node.getId() == 12045 && node.getLocation().equals(new Location(2469, 4438, 0)) && player.getLocation().getX() >= 2470) || player.getLocation().getY() < 4434 && (node.getId() == 12045 || node.getId() == 12047 && node.getLocation().equals(new Location(2465, 4434, 0))) || node.getId() == 12047 && player.getLocation().getX() >= 2470) {
DoorActionHandler.handleAutowalkDoor(player, (GameObject) node);
return true;
}
player.getDialogueInterpreter().open(MagicDoorDialogue.NAME, node);
break;
}
return true;
}
/**
* Handles the magic door dialogue.
* @author Vexia
*/
public final class MagicDoorDialogue extends DialoguePlugin {
/**
* The dialogue name.
*/
public static final String NAME = "tax door";
/**
* The object.
*/
private GameObject door;
/**
* Constructs a new {@code MagicDoorDialogue} {@code Object}.
*/
public MagicDoorDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code MagicDoorDialogue} {@code Object}.
* @param player the player.
*/
public MagicDoorDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new MagicDoorDialogue(player);
}
@Override
public boolean open(Object... args) {
door = (GameObject) args[0];
npc("You may not pass through this door without paying the", "trading tax.");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
player("So how much is the tax?");
stage++;
break;
case 1:
npc("The cost is one diamond.");
stage++;
break;
case 2:
options("Okay...", "A diamond? Are you crazy?", "I haven't brought my diamonds with me.", "What do you do with all the diamonds you get?");
stage++;
break;
case 3:
switch (buttonId) {
case 1:
player("Okay...");
stage = 10;
break;
case 2:
player("A diamond? Are you crazy?");
stage = 20;
break;
case 3:
player("I haven't brought my diamonds with me.");
stage = 30;
break;
case 4:
player("What do you do with all the diamonds you get?");
stage = 40;
break;
}
break;
case 10:
if (!player.getInventory().containsItem(Gems.DIAMOND.getGem())) {
player("...but...");
stage = 11;
} else {
end();
if (player.getInventory().remove(Gems.DIAMOND.getGem())) {
DoorActionHandler.handleAutowalkDoor(player, door);
player.getPacketDispatch().sendMessage("You give the doorman a diamond.");
}
}
break;
case 11:
player("I haven't brought my diamonds with me.");
stage = 30;
break;
case 20:
npc("Not at all. Those are the rules.");
stage++;
break;
case 21:
end();
break;
case 30:
npc("No tax, no entry.");
stage++;
break;
case 31:
end();
break;
case 40:
npc("Ever heard of fairylights? Well how do you think we", "make 'em? First we collect a pile of gems and then we", "get a spider to spin 'em into a long web, we light the", "jewels by imbuing each one with a little bit of magic.");
stage++;
break;
case 41:
player("So you're telling me fairylights are made out of gems?");
stage++;
break;
case 42:
npc("That's right, how else could we make 'em twinkle so", "beautifully?");
stage++;
break;
case 43:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 3321, DialogueInterpreter.getDialogueKey(NAME) };
}
}
}

View file

@ -0,0 +1,113 @@
package plugin.interaction.inter;
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.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.StringUtils;
/**
* Represents the plugin used to handle the agility ticket interface.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class AgilityTicketInterface extends ComponentPlugin {
/**
* Represents the pirate hook item.
*/
private static final Item PIRATE_HOOK = new Item(2997);
/**
* Represents the toadflax item.
*/
private static final Item TOADFLAX = new Item(2998);
/**
* Represents the snapdragon item.
*/
private static final Item SNAPDRAGON = new Item(3000);
/**
* Represents the aerna ticket.
*/
private static final int ARENA_TICKET = 2996;
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.forId(6).setPlugin(this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
Item reward = null;
double experience = 0;
int tickets = 0;
switch (button) {
case 21:// 1 exp
experience = 240;
tickets = 1;
break;
case 22:// 10 exp.
experience = 2480;
tickets = 10;
break;
case 23:// 25 exp.
experience = 6500;
tickets = 25;
break;
case 24:// 100 exp.
experience = 28000;
tickets = 100;
break;
case 25:// 1000 exp.
experience = 320000;
tickets = 1000;
break;
case 8:// toadflax.
reward = TOADFLAX;
tickets = 3;
break;
case 9:// snap dragon.
reward = SNAPDRAGON;
tickets = 10;
break;
case 10:// pirates hook.
reward = PIRATE_HOOK;
tickets = 800;
break;
}
if (experience > 0 && !player.getInventory().contains(ARENA_TICKET, tickets)) {
player.getPacketDispatch().sendMessage("This Agility experience costs " + tickets + " tickets.");
}
if (reward != null && !player.getInventory().contains(ARENA_TICKET, tickets)) {
player.getPacketDispatch().sendMessage(StringUtils.formatDisplayName(reward.getName().replace("Clean", "").trim()) + " costs " + tickets + " tickets.");
}
if (!player.getInventory().contains(ARENA_TICKET, tickets)) {
return true;
}
if (experience > 0) {
if (!player.getInventory().containsItem(new Item(ARENA_TICKET, tickets))) {
return false;
}
if (player.getInventory().remove(new Item(ARENA_TICKET, tickets))) {
player.getSkills().addExperience(Skills.AGILITY, experience);
player.getPacketDispatch().sendMessage("You have been granted some Agility experience!");
}
}
if (reward != null) {
if (player.getInventory().remove(new Item(ARENA_TICKET, tickets))) {
player.getInventory().add(reward);
player.getPacketDispatch().sendMessage("You have been granted a " + StringUtils.formatDisplayName(reward.getName().replace("Clean", "").trim()) + ".");
}
}
return true;
}
}

View file

@ -0,0 +1,42 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.combat.equipment.WeaponInterface;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the auto casting component plugin.
* @author Emperor
*
*/
@InitializablePlugin
public final class AutocastSelectPlugin extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.forId(797).setPlugin(this);
ComponentDefinition.forId(319).setPlugin(this);
ComponentDefinition.forId(310).setPlugin(this);
ComponentDefinition.forId(406).setPlugin(this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
if (!player.getAttribute("autocast_select", false)) {
return true;
}
player.removeAttribute("autocast_select");
final WeaponInterface w = player.getExtension(WeaponInterface.class);
if (w != null) {
w.selectAutoSpell(button, true);
player.getInterfaceManager().openTab(w);
}
return true;
}
}

View file

@ -0,0 +1,69 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.BankPinManager;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the bank pin interfaces.
* @author Vexia
*/
@InitializablePlugin
public class BankPinInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.forId(13).setPlugin(this);
ComponentDefinition.forId(14).setPlugin(this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
BankPinManager manager = player.getBankPinManager();
switch (component.getId()) {
case 14:// setting
switch (button) {
case 60:
case 62:
if (!manager.hasPin()) {
manager.toggleConfirmInterface(button == 60);
} else {
manager.setChangingState(1);
manager.openPin();
}
break;
case 63:
manager.toggleConfirmInterface(true);
break;
case 65:
manager.cancelPin("The PIN has been cancelled", "and will NOT be set.", "", "You still do not have a Bank", "PIN.");
break;
case 89:
case 91:
manager.handleConfirmInterface(button);
break;
case 61:
case 64:
manager.switchRecovery();
break;
}
break;
case 13:// pin
switch (button) {
case 30:
break;
default:
player.getBankPinManager().updateTempPin(button - 1);
break;
}
break;
}
return true;
}
}

View file

@ -0,0 +1,290 @@
package plugin.interaction.inter;
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.free.magic.MagicStaff;
import org.crandor.game.content.skill.free.magic.Runes;
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.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;
/**
* Represents the component plugin used to handle the bolt enchanting interface.
* @author Emperor
* @author SonicForce41
*/
@InitializablePlugin
public final class BoltEnchantingInterface extends ComponentPlugin {
/**
* Represents the graphics to use.
*/
private static final Graphics GRAPHICS = new Graphics(759);
/**
* Represents the animation to use.
*/
private static final Animation ANIMATION = new Animation(4462);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(432, this);
return this;
}
@Override
public boolean handle(final Player player, Component component, int opcode, int button, int slot, int itemId) {
final Bolts bolts = Bolts.forId(button);
if (bolts != null) {
player.getInterfaceManager().close();
if (player.getSkills().getLevel(Skills.MAGIC) < bolts.getLevel()) {
player.getPacketDispatch().sendMessage("You need a level of " + bolts.getLevel() + " to cast this spell.");
return true;
}
for (Item item : bolts.getRunes()) {
if (!player.getInventory().containsItem(item) && !usingStaff(player, item.getId())) {
player.getPacketDispatch().sendMessage("You do not have enough runes to cast this spell.");
return true;
}
}
final int amount = player.getInventory().getAmount(new Item(bolts.getBolt(), 1));
if (amount < 1) {
player.getPacketDispatch().sendMessage("You don't have any bolts to enchant.");
return true;
}
final Item add = new Item(bolts.getEnchanted());
if (amount > 10 && !player.getInventory().hasSpaceFor(add)) {
player.getPacketDispatch().sendMessage("Not enough space in your inventory!");
return true;
}
player.graphics(GRAPHICS);
player.animate(ANIMATION);
player.getPulseManager().run(new Pulse(1) {
@Override
public boolean pulse() {
int enchant = amount;
if (enchant > 10) {
enchant = 10;
}
add.setAmount(enchant);
player.getInventory().remove(new Item(bolts.getBolt(), enchant));
player.getInventory().add(add);
for (Item item : bolts.getRunes()) {
boolean staff = usingStaff(player, item.getId());
if (!player.getInventory().containsItem(item) && !staff) {
player.getPacketDispatch().sendMessage("You do not have enough " + item.getName() + "s to cast this spell.");
return true;
}
if (!staff) {
player.getInventory().remove(item);
}
}
player.getSkills().addExperience(Skills.MAGIC, bolts.getExp(), true);
player.getPacketDispatch().sendMessage("The magic of the runes coaxes out the true nature of the gem tips.");
return true;
}
});
return true;
}
return false;
}
/**
* Checks if the player is holding the staff that will be used instead of
* the rune.
* @param p The player.
* @param rune The rune item id.
* @return {@code True} if the player is wearing the correct staff for this
* rune.
*/
public boolean usingStaff(Player p, int rune) {
Item weapon = p.getEquipment().get(3);
if (weapon == null) {
return false;
}
MagicStaff staff = MagicStaff.forId(rune);
if (staff == null) {
return false;
}
int[] staves = staff.getStaves();
for (int id : staves) {
if (weapon.getId() == id) {
return true;
}
}
return false;
}
/**
* Represents the enumeration of bolts.
* @author SonicForce41
* @version 1
*/
public enum Bolts {
OPAL(14, 879, 4, new Item[] { new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.AIR_RUNE.getId(), 2) }, 9, 9236), SAPPHIRE(29, 9337, 7, new Item[] { new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.MIND_RUNE.getId(), 1), new Item(Runes.WATER_RUNE.getId(), 1) }, 17, 9240), JADE(18, 9335, 14, new Item[] { new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.EARTH_RUNE.getId(), 2) }, 19, 9237), PEARL(22, 880, 24, new Item[] { new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.WATER_RUNE.getId(), 2) }, 29, 9238), EMERALD(32, 9338, 27, new Item[] { new Item(Runes.NATURE_RUNE.getId(), 1), new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.AIR_RUNE.getId(), 3) }, 37, 9241), RED_TOPAZ(26, 9336, 29, new Item[] { new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.FIRE_RUNE.getId(), 2) }, 33, 9239), RUBY(35, 9339, 49, new Item[] { new Item(Runes.BLOOD_RUNE.getId(), 1), new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.FIRE_RUNE.getId(), 5) }, 59, 9242), DIAMOND(38, 9340, 57, new Item[] { new Item(Runes.LAW_RUNE.getId(), 2), new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.EARTH_RUNE.getId(), 10) }, 67, 9243), DRAGONSTONE(41, 9341, 68, new Item[] { new Item(Runes.SOUL_RUNE.getId(), 1), new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.EARTH_RUNE.getId(), 15) }, 78, 9244), ONYX(44, 9342, 87, new Item[] { new Item(Runes.DEATH_RUNE.getId(), 1), new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.FIRE_RUNE.getId(), 20) }, 97, 9245);
/**
* The button
*/
private int button;
/**
* The actual bolt
*/
private int bolt;
/**
* The level
*/
private int level;
/**
* The runes required
*/
private Item[] runes;
/**
* The exp gained
*/
private double exp;
/**
* The enchanted bolt
*/
private int enchanted;
/**
* Constructs a new {@code BoltEnchantingInterface} {@code Object}.
* @param button the button.
* @param bolt the bolt.
* @param level the level.
* @param runes the runes.
* @param exp the exp.
* @param enchanted the enchanted.
*/
Bolts(int button, int bolt, int level, Item[] runes, double exp, int enchanted) {
this.button = button;
this.bolt = bolt;
this.level = level;
this.runes = runes;
this.exp = exp;
this.enchanted = enchanted;
}
/**
* Gets the button.
* @return The button.
*/
public int getButton() {
return button;
}
/**
* Sets the button.
* @param button The button to set.
*/
public void setButton(int button) {
this.button = button;
}
/**
* Gets the bolt.
* @return The bolt.
*/
public int getBolt() {
return bolt;
}
/**
* Sets the bolt.
* @param bolt The bolt to set.
*/
public void setBolt(int bolt) {
this.bolt = bolt;
}
/**
* Gets the level.
* @return The level.
*/
public int getLevel() {
return level;
}
/**
* Sets the level.
* @param level The level to set.
*/
public void setLevel(int level) {
this.level = level;
}
/**
* Gets the runes.
* @return The runes.
*/
public Item[] getRunes() {
return runes;
}
/**
* Sets the runes.
* @param runes The runes to set.
*/
public void setRunes(Item[] runes) {
this.runes = runes;
}
/**
* Gets the exp.
* @return The exp.
*/
public double getExp() {
return exp;
}
/**
* Sets the exp.
* @param exp The exp to set.
*/
public void setExp(double exp) {
this.exp = exp;
}
/**
* Gets the enchanted.
* @return The enchanted.
*/
public int getEnchanted() {
return enchanted;
}
/**
* Sets the enchanted.
* @param enchanted The enchanted to set.
*/
public void setEnchanted(int enchanted) {
this.enchanted = enchanted;
}
/**
* Gets the bolt by the id.
* @param button the button.
* @return the bolt.
*/
public static Bolts forId(int button) {
for (Bolts bolts : Bolts.values()) {
if (bolts.getButton() == button)
return bolts;
}
return null;
}
}
}

View file

@ -0,0 +1,53 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.global.travel.canoe.Canoe;
import org.crandor.game.content.global.travel.canoe.CanoeExtension;
import org.crandor.game.content.global.travel.canoe.CanoeStation;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the canoe interface plugins.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class CanoeInterfacePlugin extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(52, this);
ComponentDefinition.put(53, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
final CanoeExtension extension = CanoeExtension.extension(player);
switch (component.getId()) {
case 52:
final Canoe canoe = Canoe.forChild(button);
if (canoe == null) {
return true;
}
extension.craft(canoe);
break;
case 53:
final CanoeStation station = CanoeStation.forButton(button);
if (station == null) {
return true;
}
if (extension.getStage() < 3) {
return true;
}
extension.travel(station);
break;
}
return true;
}
}

View file

@ -0,0 +1,34 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.global.tutorial.CharacterDesign;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents a component plugin to handle the character design interface.
* @author 'Vexia
* @version 1.9
*/
@InitializablePlugin
public final class CharacterDesignInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(771, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
switch (opcode) {
case 155:
CharacterDesign.handleButtons(player, button);
break;
}
return true;
}
}

View file

@ -0,0 +1,155 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.game.system.communication.ClanRank;
import org.crandor.game.system.communication.ClanRepository;
import org.crandor.net.amsc.MSPacketRepository;
import org.crandor.net.amsc.WorldCommunicator;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.StringUtils;
/**
* Represents the plugin used to handle the clan interfaces.
* @author Vexia
*/
@InitializablePlugin
public final class ClanInterfacePlugin extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(590, this);
ComponentDefinition.put(589, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
switch (component.getId()) {
case 589:
switch (button) {
case 9:
if (player.getInterfaceManager().getComponent(590) != null) {
player.getPacketDispatch().sendMessage("Please close the interface you have open before using 'Clan Setup'");
return true;
}
ClanRepository.openSettings(player);
return true;
case 14:
player.getDetails().getCommunication().toggleLootshare(player);
return true;
}
break;
case 590:
final ClanRepository clan = ClanRepository.get(player.getName(), true);
switch (button) {
case 23:
if (opcode == 155) {
clan.setJoinRequirement(ClanRank.NONE);
} else {
clan.setJoinRequirement(getRank(opcode));
}
player.getDetails().getCommunication().setJoinRequirement(clan.getJoinRequirement());
MSPacketRepository.setClanSetting(player, 0, clan.getJoinRequirement());
player.getPacketDispatch().sendString(clan.getJoinRequirement().getInfo(), 590, 23);
break;
case 24:
clan.setMessageRequirement(getRank(opcode));
player.getDetails().getCommunication().setMessageRequirement(clan.getMessageRequirement());
MSPacketRepository.setClanSetting(player, 1, clan.getMessageRequirement());
player.getPacketDispatch().sendString(clan.getMessageRequirement().getInfo(), 590, 24);
break;
case 25:
clan.setKickRequirement(getRank(opcode));
player.getDetails().getCommunication().setKickRequirement(clan.getKickRequirement());
MSPacketRepository.setClanSetting(player, 2, clan.getKickRequirement());
player.getPacketDispatch().sendString(clan.getKickRequirement().getInfo(), 590, 25);
clan.update();
break;
case 26:
if (opcode == 230) {
clan.setLootRequirement(ClanRank.KELDAGRIM_MOD);
} else {
clan.setLootRequirement(getRank(opcode));
}
player.getDetails().getCommunication().setLootRequirement(clan.getLootRequirement());
MSPacketRepository.setClanSetting(player, 3, clan.getLootRequirement());
player.getPacketDispatch().sendString(clan.getLootRequirement().getInfo(), 590, 26);
break;
case 22:
switch (opcode) {
case 196:
clan.setName("Chat disabled");
player.getCommunication().setClanName("");
player.getPacketDispatch().sendString(clan.getName(), 590, 22);
if (WorldCommunicator.isEnabled()) {
MSPacketRepository.sendClanRename(player, "");
break;
}
clan.clean(true);
break;
default:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
String name = StringUtils.formatDisplayName((String) value);
player.getPacketDispatch().sendString(name, 590, 22);//30
if (WorldCommunicator.isEnabled()) {
MSPacketRepository.sendClanRename(player, name);
clan.setName(name);
return true;
}
if (clan.getName().equals("Chat disabled")) {
player.getPacketDispatch().sendMessage("Your clan channel has now been enabled!");
player.getPacketDispatch().sendMessage("Join your channel by clicking 'Join Chat' and typing: " + player.getUsername());
}
clan.setName(name);
player.getCommunication().setClanName(name);
clan.update();
return true;
}
});
player.getDialogueInterpreter().sendInput(true, "Enter clan prefix:");
break;
}
break;
}
break;
}
return true;
}
/**
* Gets the value to set.
* @param opcode the opcode.
* @return the value.
*/
public static ClanRank getRank(int opcode) {
switch (opcode) {
case 155:
return ClanRank.NONE;
case 196:
return ClanRank.FRIEND;
case 124:
return ClanRank.RECRUIT;
case 199:
return ClanRank.CORPORAL;
case 234:
return ClanRank.SERGEANT;
case 168:
return ClanRank.LIEUTENANT;
case 166:
return ClanRank.CAPTAIN;
case 64:
return ClanRank.GENERAL;
case 53:
return ClanRank.OWNER;
}
return ClanRank.NONE;
}
}

View file

@ -0,0 +1,103 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.combat.CombatStyle;
import org.crandor.game.node.entity.combat.CombatSwingHandler;
import org.crandor.game.node.entity.combat.equipment.WeaponInterface;
import org.crandor.game.node.entity.combat.equipment.WeaponInterface.WeaponInterfaces;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the combat tab interface.
* @author Emperor
* @author Vexia'
* @version 1.0
*/
@InitializablePlugin
public class CombatTabInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (WeaponInterfaces inter : WeaponInterfaces.values()) {
ComponentDefinition.put(inter.getInterfaceId(), this);
}
ComponentDefinition.put(92, this);
return this;
}
@Override
public boolean handle(final Player p, Component component, int opcode, int button, int slot, int itemId) {
switch (button) {
case 7:
case 9:
case 24:
case 26:
case 27:
GameWorld.submit(new Pulse(1, p) {
@Override
public boolean pulse() {
p.getSettings().toggleRetaliating();
return true;
}
});
break;
case 11:
case 10:
case 8:
case 85:
GameWorld.submit(new Pulse(1, p) {
@Override
public boolean pulse() {
WeaponInterface inter = p.getExtension(WeaponInterface.class);
if (inter != null && inter.isSpecialBar()) {
p.getSettings().toggleSpecialBar();
if (p.getSettings().isSpecialToggled()) {
CombatSwingHandler handler;
if ((handler = CombatStyle.MELEE.getSwingHandler().getSpecial(p.getEquipment().getNew(3).getId())) != null) {
@SuppressWarnings("unchecked")
Plugin<Object> plugin = (Plugin<Object>) ((Object) handler);
if (plugin.fireEvent("instant_spec", p) == Boolean.TRUE) {
handleInstantSpec(p, handler, plugin);
}
}
}
}
return true;
}
});
break;
case 0:
default:
WeaponInterface inter = p.getExtension(WeaponInterface.class);
if (inter == null) {
return false;
}
if (inter.setAttackStyle(button)) {
if (button == 4 || button == 5) {
inter.openAutocastSelect();
} else if (p.getProperties().getAutocastSpell() != null) {
inter.selectAutoSpell(-1, false);
}
return true;
}
return false;
}
return true;
}
/**
* Method used to handle an instance special attack.
* @param p the player.
* @param handler the handler.
* @param plugin the plugin.
*/
private static void handleInstantSpec(Player p, CombatSwingHandler handler, Plugin<Object> plugin) {
handler.swing(p, p.getProperties().getCombatPulse().getVictim(), null);
}
}

View file

@ -0,0 +1,50 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
@InitializablePlugin
public class CrystalKeyChestPlugin extends ComponentPlugin {
private final Integer CHEST_INTERFACE = 501;
private Player player;
public CrystalKeyChestPlugin() {
/*
* Empty
*/
}
public CrystalKeyChestPlugin(Player player) {
this.player = player;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(CHEST_INTERFACE, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
return false;
}
public void constructInterface(Player player) {
Integer[] hiddenChildren = new Integer[] { 3, 4, 5, 6, 7};
Component component = new Component(CHEST_INTERFACE);
for (int i = 3; i < hiddenChildren.length; i++) {
player.getPacketDispatch().sendInterfaceConfig(CHEST_INTERFACE, i, true);
}
player.getPacketDispatch().sendItemOnInterface(989, 1, CHEST_INTERFACE, hiddenChildren[2]);
player.getInterfaceManager().open(component);
this.player = player;
}
}

View file

@ -0,0 +1,32 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the death interface.
* @author Vexia
*/
@InitializablePlugin
public final class DeathInterfacePlugin extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.forId(153).setPlugin(this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
if (button == 1) {
player.getSavedData().getGlobalData().setDisableDeathScreen(true);
player.getInterfaceManager().close();
}
return true;
}
}

View file

@ -0,0 +1,137 @@
package plugin.interaction.inter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.dialogue.FacialExpression;
import org.crandor.game.content.skill.free.crafting.TanningProduct;
import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.game.node.item.Item;
/**
* Represents the ellis dialogue plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class EllisDialogue extends DialoguePlugin {
/**
* Constructs a new {@code EllisDialogue} {@code Object}.
*/
public EllisDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code EllisDialogue} {@code Object}.
* @param player the player.
*/
public EllisDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new EllisDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Greetings friend I am a manufacturer of leather.");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
player.getInventory().refresh();
Item items[] = player.getInventory().toArray();
for (int i = 0; i < items.length; i++) {
if (items[i] == null) {
continue;
}
if (TanningProduct.forItemId(items[i].getId()) != null) {
interpreter.sendDialogues(npc, null, "I see you have brought me some hides.", "Would you like me to tan them for you?");
stage = 100;
return true;
}
}
interpreter.sendOptions("What would you like to say?", "Can I buy some leather?", "Leather is rather weak stuff.");
stage = 1;
break;
case 1:
switch (buttonId) {
case 1:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Can I buy some leather then?");
stage = 10;
break;
case 2:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Leather is rather weak stuff.");
stage = 3000;
break;
}
break;
case 10:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "I make leather from animal hides. Bring me some cowhides", "and one gold coin per hide, and I'll tan them into soft", "leather for you.");
stage = 2000;
break;
case 2000:
end();
break;
case 3000:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Normal leather may be quite weak, but it's very cheap - I", "make it from cowhides for only 1 gp per hide - and it's so", "easy to craft that anyone can work with it.");
stage = 3001;
break;
case 3001:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Alernatively you could try hard leather. It's not so easy", "to craft, but I only charge 3 gp per cowhide to prepare it,", "and it makes much sturdier armour.");
stage = 3002;
break;
case 3002:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Thanks; I'll bear it in mind.");
stage = 3003;
break;
case 3003:
end();
break;
case 100:
interpreter.sendOptions("Select an Option", "Yes please.", "No thanks.");
stage = 101;
break;
case 101:
switch (buttonId) {
case 1:
interpreter.sendDialogues(player, null, "Yes please.");
stage = 210;
break;
case 2:
interpreter.sendDialogues(player, null, "No thanks.");
stage = 200;
break;
}
break;
case 210:
end();
TanningProduct.open(player, 2824);
break;
case 200:
interpreter.sendDialogues(npc, null, "Very well, sir, as you wish.");
stage = 201;
break;
case 201:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 2824 };
}
}

View file

@ -0,0 +1,30 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.emote.Emotes;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the emote tab interface.
* @author Vexia
*
*/
@InitializablePlugin
public final class EmoteTabInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(464, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
Emotes.handle(player, button);
return true;
}
}

View file

@ -0,0 +1,200 @@
package plugin.interaction.inter;
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.container.Container;
import org.crandor.game.container.ContainerEvent;
import org.crandor.game.container.ContainerListener;
import org.crandor.game.container.access.BitregisterAssembler;
import org.crandor.game.container.access.InterfaceContainer;
import org.crandor.game.container.impl.EquipmentContainer;
import org.crandor.game.content.global.action.EquipHandler;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.entity.combat.DeathTask;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.prayer.PrayerType;
import org.crandor.game.node.item.Item;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.net.packet.PacketRepository;
import org.crandor.net.packet.context.ContainerContext;
import org.crandor.net.packet.out.ContainerPacket;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the equipment interface.
* @author Emperor
*
*/
@InitializablePlugin
public final class EquipmentInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(387, this);
ComponentDefinition.put(667, this);
ComponentDefinition.put(670, this);
return this;
}
@Override
public boolean handle(final Player p, Component component, int opcode, int button, final int slot, final int itemId) {
if (component.getId() == 667) {
if (button != 14) {
return false;
}
switch (opcode) {
case 155:
p.getPulseManager().clear();
GameWorld.submit(new Pulse(1, p) {
@Override
public boolean pulse() {
EquipHandler.unequip(p, slot, itemId);
return true;
}
});
return true;
case 9:
p.sendMessage(p.getEquipment().get(slot).getDefinition().getExamine());
return true;
case 196:
GameWorld.submit(new Pulse(1, p) {
@Override
public boolean pulse() {
operate(p, slot, itemId);
return true;
}
});
return true;
}
return false;
}
else if (component.getId() == 670) {
switch (opcode) {
case 155:
p.getPulseManager().clear();
final Item item = p.getInventory().get(slot);
GameWorld.submit(new Pulse(1, p) {
@Override
public boolean pulse() {
EquipHandler.SINGLETON.handle(p, item, "equip");
return true;
}
});
return true;
case 9:
p.sendMessage(p.getInventory().get(slot).getDefinition().getExamine());
return true;
}
}
switch (opcode) {
case 206:
if (button != 28) {
return false;
}
GameWorld.submit(new Pulse(1, p) {
@Override
public boolean pulse() {
operate(p, slot, itemId);
return true;
}
});
return true;
default:
switch (button) {
case 52:
if (p.getInterfaceManager().isOpened() && p.getInterfaceManager().getOpened().getId() == 102) {
return true;
}
boolean skulled = p.getSkullManager().isSkulled();
boolean usingProtect = p.getPrayer().get(PrayerType.PROTECT_ITEMS);
p.getInterfaceManager().openComponent(102);
p.getPacketDispatch().sendAccessMask(211, 0, 2, 6684690, 4);
p.getPacketDispatch().sendAccessMask(212, 0, 2, 6684693, 42);
Container[] itemArray = DeathTask.getContainers(p);
Container kept = itemArray[0];
int state = 0; // 1=familiar carrying items
int keptItems = skulled ? (usingProtect ? 1 : 0) : (usingProtect ? 4 : 3);
int zoneType = p.getZoneMonitor().getType();
int pvpType = p.getSkullManager().isWilderness() ? 0 : 1;
Object[] params = new Object[] { 11510, 12749, "", state, pvpType, kept.getId(3), kept.getId(2), kept.getId(1), kept.getId(0), keptItems, zoneType };
PacketRepository.send(ContainerPacket.class, new ContainerContext(p, 149, 0, 91, itemArray[1], false));
p.getPacketDispatch().sendRunScript(118, "iiooooiisii", params);
break;
case 28:
if (opcode == 81) {
p.getPulseManager().clear();
GameWorld.submit(new Pulse(1, p) {
@Override
public boolean pulse() {
EquipHandler.unequip(p, slot, itemId);
return true;
}
});
return true;
}
break;
case 55:
if (p.getInterfaceManager().isOpened() && p.getInterfaceManager().getOpened().getId() == 667) {
return true;
}
final ContainerListener listener = new ContainerListener() {
@Override
public void update(Container c, ContainerEvent e) {
PacketRepository.send(ContainerPacket.class, new ContainerContext(p, -1, -1, 98, e.getItems(), false, e.getSlots()));
}
@Override
public void refresh(Container c) {
PacketRepository.send(ContainerPacket.class, new ContainerContext(p, -1, -1, 98, c, false));
}
};
p.getInterfaceManager().openComponent(667).setCloseEvent((player, c) -> {
player.removeAttribute("equip_stats_open");
player.getInterfaceManager().closeSingleTab();
player.getInventory().getListeners().remove(listener);
return true;
});
p.setAttribute("equip_stats_open", true);
EquipmentContainer.update(p);
p.getInterfaceManager().openSingleTab(new Component(670));
InterfaceContainer.generateItems(p, p.getInventory().toArray(), new String[] { "Equip" }, 670, 0, 7, 4, 93);
BitregisterAssembler assembly = new BitregisterAssembler(new String[] { "Equip" });
assembly.enableExamineOption();
assembly.enableSlotSwitch();
p.getPacketDispatch().sendAccessMask(assembly.calculateRegister(), 0, 670, 0, 27);
p.getInventory().getListeners().add(listener);
p.getInventory().refresh();
ItemDefinition.statsUpdate(p);
p.getPacketDispatch().sendAccessMask(1278, 14, 667, 0, 13);
break;
}
}
return true;
}
/**
* Operates an item.
* @param player The player.
* @param slot The container slot.
* @param itemId The item id.
*/
public void operate(Player player, int slot, int itemId) {
if (slot < 0 || slot > 13) {
return;
}
Item item = player.getEquipment().get(slot);
if (item == null) {
return;
}
OptionHandler handler = item.getOperateHandler();
if (handler != null && handler.handle(player, item, "operate")) {
return;
}
player.getPacketDispatch().sendMessage("You can't operate that.");
}
}

View file

@ -0,0 +1,138 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.global.Lamps;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.events.GlobalEventManager;
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.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the experience lamp interface.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class ExperienceLampInterface extends ComponentPlugin {
/**
* Represents the sound to send.
*/
private static final Audio SOUND = new Audio(1270, 12, 1);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(134, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
Item lamp = player.getAttribute("lamp", null);
if (lamp == null) {
return true;
}
if (button == 37 && !player.getQuestRepository().isComplete("Drudic Ritual")) {
player.getPacketDispatch().sendMessage("You need to complete the Druidic Ritual quest to start that skill.");
return true;
}
if (button == 52 && !player.getQuestRepository().isComplete("Wolf Whistle")) {
player.getPacketDispatch().sendMessage("You need to complete the Wolf Whistle quest to start that skill.");
return true;
}
if (button == 47 && !player.getQuestRepository().isComplete("Rune Mysteries")) {
player.getPacketDispatch().sendMessage("You need to complete the Rune Mysteries quest to start that skill.");
return true;
}
if (button != 2) {
player.setAttribute("lamp:experience", button);
}
if (button == 2) {
if (!player.getAttributes().containsKey("lamp:experience")) {
player.getPacketDispatch().sendMessage("You need to pick the skill you wish to gain the experience in first.");
return true;
}
final SkillInterface skillType = SkillInterface.forId((int) player.getAttribute("lamp:experience"));
if (skillType == null || skillType.button == 24) {
return true;
}
if (skillType == SkillInterface.RUNECRAFTING && !player.getQuestRepository().isComplete("Rune Mysteries")) {
player.getPacketDispatch().sendMessage("You need to complete the Rune Mysteries quest to start that skill.");
return true;
}
if (!player.getInventory().containsItem(lamp)) {
return true;
}
Lamps type = Lamps.forItem(lamp);
if (player.getSkills().getStaticLevel(skillType.skill) <= type.getLevelRequirement()) {
player.sendMessage("You need a level in this skill which is greater than " + type.getLevelRequirement() + ".");
return true;
}
player.getAudioManager().send(SOUND);
player.getInventory().remove(lamp);
player.getInterfaceManager().close();
int x = player.getSkills().getStaticLevel(skillType.skill);
int modifier = 10;
double experience = x * modifier;
if (type != null && type != Lamps.GENIE_LAMP) {
player.getDialogueInterpreter().open(70099, new Object[] { "The lamp gives you " + (int) type.getExp() + " " + Skills.SKILL_NAME[skillType.skill] + " experience." });
experience = type.getExp() / Skills.EXPERIENCE_MULTIPLIER;
int skill = skillType.skill;
if (skill == Skills.ATTACK || skill == Skills.DEFENCE || skill == Skills.HITPOINTS || skill == Skills.STRENGTH || skill == Skills.STRENGTH || skill == Skills.MAGIC || skill == Skills.RANGE) {
experience /= 2;
}
} else {
player.getDialogueInterpreter().open(70099, new Object[] { "The lamp gives you " + (experience * (Skills.EXPERIENCE_MULTIPLIER * (GlobalEventManager.get().isActive("XPFever") ? 2 : 1))) + " " + Skills.SKILL_NAME[skillType.skill] + " experience." });
}
player.getSkills().addExperience(skillType.skill, experience, false);
}
return true;
}
/**
* Representa a skill to gain experience.
* @author 'Vexia
*/
public enum SkillInterface {
ATTACK(29, Skills.ATTACK), STRENGTH(30, Skills.STRENGTH), RANGE(32, Skills.RANGE), MAGIC(35, Skills.MAGIC), DEFENCE(31, Skills.DEFENCE), CRAFTING(39, Skills.CRAFTING), HITPOINTS(34, Skills.HITPOINTS), PRAYER(33, Skills.PRAYER), AGILITY(36, Skills.AGILITY), HERBLORE(37, Skills.HERBLORE), THIEVING(38, Skills.THIEVING), FISHING(43, Skills.FISHING), RUNECRAFTING(47, Skills.RUNECRAFTING), SLAYER(48, Skills.SLAYER), FARMING(50, Skills.FARMING), MINING(41, Skills.MINING), SMITHING(42, Skills.SMITHING), HUNTER(49, Skills.HUNTER), SUMMONING(52, Skills.SUMMONING), COOKING(45, Skills.COOKING), FIREMAKING(44, Skills.FIREMAKING), WOODCUTTING(46, Skills.WOODCUTTING), FLETCHING(40, Skills.FLETCHING);
/**
* Constructs a new {@code ExperienceLampInterface} {@code Object}.
* @param button the button.
* @param skill the skill.
*/
SkillInterface(int button, int skill) {
this.button = button;
this.skill = skill;
}
/**
* The button id.
*/
private final int button;
/**
* The skill id.
*/
private final int skill;
/**
* Gets the skill type for the button.
* @param id the id.
* @return the skill type.
*/
public static SkillInterface forId(int id) {
for (SkillInterface lamp : SkillInterface.values()) {
if (lamp.button == id) {
return lamp;
}
}
return null;
}
}
}

View file

@ -0,0 +1,347 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.container.Container;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.dialogue.FacialExpression;
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.net.packet.PacketRepository;
import org.crandor.net.packet.context.ContainerContext;
import org.crandor.net.packet.out.ContainerPacket;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin related to the custom fur clothing interface.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class FurClothingInterface extends ComponentPlugin {
/**
* Represents the item array of clothing.
*/
private static final Item[] ITEMS = new Item[] { new Item(10065), new Item(10067), new Item(10053), new Item(10055), new Item(10057), new Item(10059), new Item(10061), new Item(10063), new Item(10075), new Item(10069), new Item(10045), new Item(10043), new Item(10041), new Item(10051), new Item(10049), new Item(10047), new Item(10039), new Item(10037), new Item(10035), new Item(10071) };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(477, this);
new FancyDressOwnerDialogue().init();
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
final Object[] data = FurClothing.getData(slot);
if (data == null) {
return false;
}
final FurClothing clothing = ((FurClothing) data[0]);
final int index = (int) data[1];
switch (opcode) {
case 133:
switch (button) {
case 75:
player.getPacketDispatch().sendMessage(clothing.getValueMessage(index));
break;
}
break;
case 236:// 1
clothing.buy(player, index, 1);
break;
case 157:// 5
clothing.buy(player, index, 5);
break;
case 243:// 10
clothing.buy(player, index, 10);
break;
}
return true;
}
/**
* Method used to open the fur clothing interface.
* @param player the player.
*/
public static void open(final Player player) {
player.getInterfaceManager().open(new Component(477));
PacketRepository.send(ContainerPacket.class, new ContainerContext(player, 477, 75, 91, new Container(21, ITEMS), true));
}
/**
* Represents fur clothing.
* @author 'Vexia
* @version 1.0
*/
public enum FurClothing {
POLAR(new Item[][] { { new Item(10117, 2), new Item(10065), new Item(995, 20) }, { new Item(10117, 2), new Item(10067), new Item(995, 20) } }, 0, 1), COMMON(new Item[][] { { new Item(10121, 2), new Item(10053), new Item(995, 20) }, { new Item(10121, 2), new Item(10055), new Item(995, 20) } }, 2, 3), FELDIP(new Item[][] { { new Item(10119, 2), new Item(10057), new Item(995, 20) }, { new Item(10119, 2), new Item(10059), new Item(995, 20) } }, 4, 5), DESERT(new Item[][] { { new Item(10123, 2), new Item(10061), new Item(995, 20) }, { new Item(10123, 2), new Item(10063), new Item(995, 20) } }, 6, 7), LARUPIA(new Item[][] { { new Item(10095), new Item(10045), new Item(995, 500) }, { new Item(10095), new Item(10043), new Item(995, 100) }, { new Item(10095), new Item(10041), new Item(995, 100) } }, 10, 11, 12), GRAAHK(new Item[][] { { new Item(10099), new Item(10051), new Item(995, 750) }, { new Item(10099), new Item(10049), new Item(995, 150) }, { new Item(10099), new Item(10047), new Item(995, 150) } }, 13, 14, 15), KYATT(new Item[][] { { new Item(10103), new Item(10039), new Item(995, 1000) }, { new Item(10103), new Item(10037), new Item(995, 250) }, { new Item(10103), new Item(10035), new Item(995, 250) } }, 16, 17, 18), DARK_KEBBIT(new Item[][] { { new Item(10115, 2), new Item(10075), new Item(995, 600) } }, 8), SPOTTED_KEBBIT(new Item[][] { { new Item(10125, 2), new Item(10069), new Item(995, 400) } }, 9), DASHING_KEBBIT(new Item[][] { { new Item(10127, 2), new Item(10071), new Item(995, 800) } }, 19);
/**
* Represents the items of the clothing in paralled to childs.
*/
private final Item[][] clothing;
/**
* Represents the child ids of the clothing set.
*/
private final int[] childs;
/**
* Constructs a new {@code FancyDressOwnerDialogue} {@code Object}.
* @param clothing the clothing.
* @param childs the childs.
*/
FurClothing(final Item[][] clothing, final int... childs) {
this.clothing = clothing;
this.childs = childs;
}
/**
* Method used to buy a clothing piece.
* @param player the player.
* @param index the index.
* @param amount the amount.
*/
public void buy(final Player player, final int index, int amount) {
if (!player.getInventory().containsItem(getCoins(index))) {
player.getPacketDispatch().sendMessage("You don't have enough coins.");
return;
}
if (!isAnyFur(index) ? !player.getInventory().containsItem(getFur(index)) : (!player.getInventory().containsItem(getFur(index, true))) && !player.getInventory().containsItem(getFur(index))) {
player.getPacketDispatch().sendMessage("You don't have the material required to make this item.");
return;
}
final Item fur = !isAnyFur(index) ? getFur(index) : !player.getInventory().containsItem(getFur(index)) ? getFur(index, true) : getFur(index);
int inventoryAmount = player.getInventory().getAmount(fur);
if (amount > inventoryAmount) {
amount = inventoryAmount;
}
final Item coins = new Item(995, getCoins(index).getAmount() * amount);
if (!player.getInventory().containsItem(coins)) {
player.getPacketDispatch().sendMessage("You don't have enough coins.");
return;
}
if (player.getInventory().remove(coins, new Item(fur.getId(), fur.getAmount() * amount))) {
player.getInventory().add(new Item(getProduct(index).getId(), amount != 1 ? amount / fur.getAmount() : amount));
}
}
/**
* Gets the tile child.
* @return the title.
*/
public int getTitleChild() {
return childs[0];
}
/**
* Gets the fur item.
* @param index the index.
* @param all if both furs.
* @return the fur.
*/
public Item getFur(int index, boolean all) {
return all ? (new Item(clothing[index][0].getId() - 2)) : clothing[index][0];
}
/**
* Gets the fur item.
* @param index the index.
* @return the fur.
*/
public Item getFur(int index) {
return getFur(index, false);
}
/**
* Gets the product item.
* @param index the index.
* @return the product.
*/
public Item getProduct(int index) {
return clothing[index][1];
}
/**
* Gets the coins item.
* @param index the index.
* @return the coins.
*/
public Item getCoins(int index) {
return clothing[index][2];
}
/**
* Checks if it takes any type of fur(tatty or not).
* @param index the index.
* @return {@code True} if so.
*/
public boolean isAnyFur(int index) {
return index > 0 && ordinal() > 3 && ordinal() < 7;
}
/**
* Gets the value message.
* @param index the index.
* @return the value message.
*/
public String getValueMessage(int index) {
return getProduct(index).getName() + ": Requires " + (isAnyFur(index) ? "any " : "") + getFur(index).getAmount() + " " + getFur(index).getName().toLowerCase() + (getFur(index).getAmount() > 1 ? "s" : "") + " and " + getCoins(index).getAmount() + " coins.";
}
/**
* Gets the clothing.
* @return the clothing.
*/
public Item[][] getClothing() {
return clothing;
}
/**
* Gets the childs.
* @return the childs.
*/
public int[] getChilds() {
return childs;
}
/**
* Method used to get the data by the slot.
* @param slot the slot.
* @return the clothing & the current index.
*/
public static Object[] getData(int slot) {
for (FurClothing cloth : values()) {
for (int i = 0; i < cloth.getChilds().length; i++) {
if (cloth.getChilds()[i] == slot) {
return new Object[] { cloth, i };
}
}
}
return null;
}
}
/**
* Represents the fancy dress owner dialogue plugin.
* @author 'Vexia
* @version 1.0
*/
public final class FancyDressOwnerDialogue extends DialoguePlugin {
/**
* Constructs a new {@code FancyDressOwnerDialogue} {@code Object}.
*/
public FancyDressOwnerDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code FancyDressOwnerDialogue} {@code Object}.
* @param player the player.
*/
public FancyDressOwnerDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new FancyDressOwnerDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Now you look like someone who goes to a lot of fancy", "dress parties.");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Errr....what are you saying exactly?");
stage = 1;
break;
case 1:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "I'm just saying that perhaps you would like to persure my", "selection of garments.");
stage = 2;
break;
case 2:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Or, if that doesn't interest you, then maybe you have", "something else to offer? I'm always on the lookout for", "interesting or unusual new materials.");
stage = 3;
break;
case 3:
interpreter.sendOptions("Select an Option", "Okay, let's see what you've got, then.", "I think I might just leave the persuing for now, thanks.", "Can you make clothing sutiable for hunting?", "What sort of unusual materials did you have in mind?");
stage = 4;
break;
case 4:
switch (buttonId) {
case 1:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Okay, let's see what you've got, then.");
stage = 10;
break;
case 2:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "I think I might just leave the persuing for now, thanks.");
stage = 100;
break;
case 3:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Can you make clothing suitable for hunting?");
stage = 30;
break;
case 4:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "What sort of unusual materials did you have in mind?");
stage = 41;
break;
}
break;
case 100:
end();
break;
case 30:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Certainly. Take a look at my range of made-to-oder", "items. If you can supply the furs, I'll gladly make any of", "these for you.");
stage = 31;
break;
case 31:
end();
FurClothingInterface.open(player);
break;
case 41:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Well, soem more colourful feathers might be useful. For", "some surreal reason, all I normally seem to get offered", "are large quantities of rather beaten-up looking chicken", "feathers.");
stage = 42;
break;
case 42:
interpreter.sendDialogues(npc, FacialExpression.NORMAL, "People must have some very strange pastimes around", "these parts, that's all I can say.");
stage = 43;
break;
case 43:
interpreter.sendDialogues(player, FacialExpression.NORMAL, "Ok, let's see what you've got then.");
stage = 44;
break;
case 44:
case 10:
end();
npc.openShop(player);
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 554 };
}
}
}

View file

@ -0,0 +1,212 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.global.tutorial.TutorialSession;
import org.crandor.game.content.global.tutorial.TutorialStage;
import org.crandor.game.node.entity.combat.equipment.WeaponInterface;
import org.crandor.game.node.entity.combat.equipment.WeaponInterface.WeaponInterfaces;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.info.Rights;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.RegionManager;
import org.crandor.net.packet.PacketRepository;
import org.crandor.net.packet.context.InterfaceConfigContext;
import org.crandor.net.packet.out.InterfaceConfig;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the component plugin used for the game interface.
* @author Vexia
*
*/
@InitializablePlugin
public final class GameInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(548, this);
ComponentDefinition.put(750, this);
ComponentDefinition.put(751, this);
ComponentDefinition.put(740, this);
return this;
}
@Override
public boolean handle(final Player player, Component component, int opcode, int button, int slot, int itemId) {
switch (component.getId()) {
case 740:
switch (button){
case 3:
player.getInterfaceManager().closeChatbox();
break;
}
return true;
case 548:
int tut_stage = TutorialSession.getExtension(player).getStage();
if (button >= 38 && button<= 44 || button >= 20 && button <= 26) {
player.getInterfaceManager().setCurrentTabIndex(getTabIndex(button));
}
switch (button) {
case 21://friends tab
if (tut_stage == 63) {
player.getConfigManager().set(1021, 0);
TutorialStage.load(player, 64, false);
}
break;
case 22://ignore tab
if (tut_stage == 64) {
player.getConfigManager().set(1021, 0);
TutorialStage.load(player, 65, false);
}
break;
case 24://settings tab
if (tut_stage == 1) {
TutorialStage.load(player, 2, false);
}
break;
case 38://attack tab
if (tut_stage == 49) {
player.getConfigManager().set(1021, 0);
TutorialStage.load(player, 50, false);
} else {
if (TutorialSession.getExtension(player).getStage() > TutorialSession.MAX_STAGE) {
if (player.getExtension(WeaponInterface.class) == WeaponInterfaces.STAFF) {
final Component c = new Component(WeaponInterfaces.STAFF.getInterfaceId());
player.getInterfaceManager().openTab(0, c);
final WeaponInterface inter = player.getExtension(WeaponInterface.class);
inter.updateInterface();
}
}
}
break;
case 39://skill tab
if (tut_stage == 10) {
player.getConfigManager().set(1021, 0);
TutorialStage.load(player, 11, false);
}
break;
case 40://quest tab
if (tut_stage == 27) {
TutorialStage.load(player, 28, false);
}
/*if (GameWorld.isEconomyWorld()) {
player.getQuestRepository().syncronizeTab(player);
} else {
player.getSavedData().getSpawnData().drawStatsTab(player);
}*/
player.getQuestRepository().syncronizeTab(player);
break;
case 41://invy tab
if (tut_stage == 5) {
player.getConfigManager().set(1021, 0);
TutorialStage.load(player, 6, false);
}
player.getInventory().refresh();
break;
case 42://equipment tab
if (tut_stage == 45) {
player.getConfigManager().set(1021, 0);
TutorialStage.load(player, 46, false);
}
break;
case 43://prayer tab
if (tut_stage == 61) {
player.getConfigManager().set(1021, 0);
TutorialStage.load(player, 62, false);
}
break;
case 44://magic tab
if (tut_stage == 68) {
player.getConfigManager().set(1021, 0);
TutorialStage.load(player, 69, false);
player.getDialogueInterpreter().open(946, RegionManager.getNpc(player, 946));
}
break;
case 66: // World map
case 110:
configureWorldMap(player);
break;
case 69://Logout
player.getPacketDispatch().sendString("When you have finished playing " + GameWorld.getName() + ", always use the button below to logout safely. ", 182, 0);
break;
}
return true;
case 750:
switch (opcode) {
case 155:
switch (button) {
case 1:
player.getSettings().toggleRun();
break;
}
break;
}
return true;
case 751:
switch (opcode) {
case 155:
switch (button) {
case 27:
openReport(player);
break;
}
break;
}
return true;
}
return true;
}
/**
* Method used to open the report interface.
* @param player the player.
*/
public static void openReport(final Player player) {
player.getInterfaceManager().open(new Component(553)).setCloseEvent((player1, c) -> {
player1.getPacketDispatch().sendRunScript(80, "");
player1.getPacketDispatch().sendRunScript(137, "");
return true;
});
player.getPacketDispatch().sendRunScript(508, "");
if (player.getDetails().getRights() != Rights.REGULAR_PLAYER) {
for (int i = 0; i < 18; i++) {
player.getPacketDispatch().sendInterfaceConfig(553, i, false);
}
}
}
/**
* Gets the tab index.
* @param button The button id.
* @return The tab index.
*/
private static int getTabIndex(int button) {
int tabIndex = button - 38;
if (button < 27) {
tabIndex = (button - 20) + 7;
}
return tabIndex;
}
/**
* Configures the world map for a player.
* @param player The player.
*/
private void configureWorldMap(Player player) {
if (player.inCombat()) {
player.getPacketDispatch().sendMessage("It wouldn't be very wise opening the world map during combat.");
return;
}
player.getPacketDispatch().sendWindowsPane(755, 0);
int hash = player.getLocation().getX() << 14 | player.getLocation().getY();
// player.getPacketDispatch().sendRunScript(622, "", hash);
// player.getPacketDispatch().sendRunScript(674, "", hash);
PacketRepository.send(InterfaceConfig.class, new InterfaceConfigContext(player, 371, 25, true));
player.setAttribute("worldMap:viewing", true);
}
}

View file

@ -0,0 +1,123 @@
package plugin.interaction.inter;
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.free.crafting.GlassProduct;
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.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;
/**
* Represents the glass making interface plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class GlassInterface extends ComponentPlugin {
/**
* Represents the animation to use.
*/
private static final Animation ANIMATION = new Animation(884);
/**
* Represents the molten glass item.
*/
private static final Item MOLTEN_GLASS = new Item(1775);
/**
* Represents the soda ash item.
*/
private static final Item SODA_ASH = new Item(1781, 1);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(542, this);
return this;
}
@Override
public boolean handle(final Player p, Component component, int opcode, int button, int slot, int itemId) {
final GlassProduct def = GlassProduct.forId(button);
if (def == null) {
return true;
}
if (!p.getInventory().contains(1785, 1)) {
p.getPacketDispatch().sendMessage("You need a glassblowing pipe to do this.");
return true;
}
if (!p.getInventory().contains(1775, 1)) {
p.getPacketDispatch().sendMessage("You need molten glass to do this.");
return true;
}
if (p.getSkills().getLevel(Skills.CRAFTING) < def.getLevel()) {
p.getPacketDispatch().sendMessage("You need a crafting level of " + def.getLevel() + " to make this.");
return true;
}
int real = -1;
switch (opcode) {
case 230:
real = 1;
break;
case 205:
real = 5;
break;
case 127:
real = p.getInventory().getAmount(MOLTEN_GLASS);
break;
case 211:
p.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int ammount = (int) value;
make(p, def, ammount);
return true;
}
});
p.getDialogueInterpreter().sendInput(false, "Enter the amount.");
break;
}
if (opcode == 211) {
return true;
}
make(p, def, real);
return true;
}
/**
* Method used to make a glass product.
* @param player the player.
* @param glass the glass.
* @param amount the amount.
*/
public static void make(final Player player, final GlassProduct glass, final int amount) {
player.getInterfaceManager().close();
player.animate(ANIMATION);
GameWorld.submit(new Pulse(2, player) {
int amt = amount;
@Override
public boolean pulse() {
if (!player.getInventory().contains(1775, 1) || amt == 0) {
return true;
}
player.animate(ANIMATION);
player.getInventory().remove(MOLTEN_GLASS);
player.getInventory().remove(SODA_ASH);
player.getInventory().add(new Item(glass.getProduct(), 1));
player.getSkills().addExperience(Skills.CRAFTING, glass.getExperience(), true);
player.getPacketDispatch().sendMessage("You make a " + new Item(glass.getProduct()).getName().toLowerCase().replace("unpowered", "").trim() + ".");
amt--;
return false;
}
});
}
}

View file

@ -0,0 +1,36 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.global.travel.glider.GliderPulse;
import org.crandor.game.content.global.travel.glider.Gliders;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the glider interface component.
* @author Emperor
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class GliderInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(138, this);
return this;
}
@Override
public boolean handle(final Player player, Component component, int opcode, int button, int slot, int itemId) {
final Gliders glider = Gliders.forId(button);
if (glider == null) {
return true;
}
player.getPulseManager().run(new GliderPulse(1, player, glider));
return true;
}
}

View file

@ -0,0 +1,430 @@
package plugin.interaction.inter;
import org.crandor.cache.def.impl.CS2Mapping;
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.eco.ge.GEGuidePrice;
import org.crandor.game.content.eco.ge.GEItemSet;
import org.crandor.game.content.eco.ge.GrandExchange;
import org.crandor.game.content.eco.ge.GrandExchangeOffer;
import org.crandor.game.content.eco.ge.OfferState;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.game.node.entity.player.link.audio.Audio;
import org.crandor.game.node.item.Item;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.net.packet.PacketRepository;
import org.crandor.net.packet.context.ContainerContext;
import org.crandor.net.packet.out.ContainerPacket;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the Grand Exchange interface options.
* @author Emperor
* @version 1.0
*/
@InitializablePlugin
public class GrandExchangeInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(105, this); // Main interface
ComponentDefinition.put(107, this); // Selling tab
ComponentDefinition.put(109, this); // Collection interface
ComponentDefinition.put(389, this); // Search interface
ComponentDefinition.put(644, this); // Item sets inventory interface
ComponentDefinition.put(645, this); // Item sets interface
ComponentDefinition.put(642, this); // Guide Prices interface.
return this;
}
/**
* Increments the opened grand exchange offer amount.
* @param player The player.
* @param amount The amount to increment.
*/
@SuppressWarnings("deprecation")
private void setOfferAmount(Player player, GrandExchangeOffer offer, int amount) {
if (offer == null || amount < 0 || offer.getState() != OfferState.PENDING) {
return;
}
offer.setAmount(amount);
player.getConfigManager().send(1110, offer.getAmount());
}
/**
* Increments the opened grand exchange offer amount.
* @param player The player.
* @param amount The amount to increment.
*/
@SuppressWarnings("deprecation")
private void setOfferValue(Player player, GrandExchangeOffer offer, int value) {
if (offer == null || value < 1 || offer.getState() != OfferState.PENDING) {
return;
}
if (value == offer.getEntry().getValue()) {
player.getAudioManager().send(new Audio(4043, 1, 1));
} else if (value > offer.getOfferedValue()) {
player.getAudioManager().send(new Audio(4041, 1, 1));
} else {
player.getAudioManager().send(new Audio(4045, 1, 1));
}
offer.setOfferedValue(value);
player.getConfigManager().send(1111, offer.getOfferedValue());
}
@Override
public boolean handle(final Player player, final Component component, final int opcode, final int button, final int slot, final int itemId) {
GameWorld.submit(new Pulse(1, player) {
@Override
public boolean pulse() {
switch (component.getId()) {
case 644:
case 645:
handleItemSet(player, component, opcode, button, slot, itemId);
return true;
case 389:
handleSearchInterface(player, opcode, button, slot, itemId);
return true;
case 107:
handleSellingTab(player, opcode, button, slot, itemId);
return true;
case 109:
handleCollectionBox(player, opcode, button, slot, itemId);
return true;
case 642:
handleGuidePrice(player, opcode, button, slot, itemId);
return true;
}
handleMainInterface(player, opcode, button, slot, itemId);
return true;
}
});
return true;
}
/**
* Handles the search interface options.
* @param player The player.
* @param opcode The packet opcode.
* @param button The button id.
* @param slot The slot.
* @param itemId The item id.
* @return {@code true} if the option got handled.
*/
public boolean handleSearchInterface(final Player player, int opcode, int button, int slot, int itemId) {
switch (button) {
case 10:
player.getInterfaceManager().closeChatbox();
return true;
}
return false;
}
/**
* Handles the selling tab interface options.
* @param player The player.
* @param opcode The packet opcode.
* @param button The button id.
* @param slot The slot.
* @param itemId The item id.
* @return {@code true} if the option got handled.
*/
public boolean handleSellingTab(final Player player, int opcode, int button, int slot, int itemId) {
if (button != 18 || slot < 0 || slot > 27) {
return false;
}
Item item = player.getInventory().get(slot);
if (item == null) {
return false;
}
switch (opcode) {
case 196:
player.getPacketDispatch().sendMessage(item.getDefinition().getExamine());
return true;
case 155:
player.getGrandExchange().constructSale(item);
return true;
}
return false;
}
/**
* Handles the selling tab interface options.
* @param player The player.
* @param opcode The packet opcode.
* @param button The button id.
* @param slot The slot.
* @param itemId The item id.
* @return {@code true} if the option got handled.
*/
public boolean handleCollectionBox(final Player player, int opcode, int button, int slot, int itemId) {
int index = -1;
switch (button) {
case 18:
case 23:
case 28:
index = (button - 18) >> 2;
break;
case 36:
case 44:
case 52:
index = 3 + ((button - 36) >> 3);
break;
}
GrandExchangeOffer offer;
if (index > -1 && (offer = player.getGrandExchange().getOffers()[index]) != null) {
player.getGrandExchange().withdraw(offer, slot >> 1);
}
return true;
}
/**
* Handles the item set.
* @param player The player.
* @param opcode The opcode.
* @param button The button.
* @param slot The slot.
* @param itemId The item id.
*/
private void handleItemSet(Player player, Component component, int opcode, int button, int slot, int itemId) {
if (button != 16 && button != 0) {
return;
}
boolean inventory = component.getId() == 644;
if (slot < 0 || slot >= (inventory ? 28 : GEItemSet.values().length)) {
return;
}
GEItemSet set = GEItemSet.values()[slot];
Item item = inventory ? player.getInventory().get(slot) : new Item(set.getItemId());
if (item == null) {
return;
}
if (opcode != 127 && inventory && ((set = GEItemSet.forId(item.getId())) == null)) {
player.getPacketDispatch().sendMessage("This isn't a set item.");
return;
}
switch (opcode) {
case 124:
player.getPacketDispatch().sendMessage(item.getDefinition().getExamine());
break;
case 196:
if (inventory) {
if (player.getInventory().freeSlots() < set.getComponents().length - 1) {
player.getPacketDispatch().sendMessage("You don't have enough inventory space for the component parts.");
return;
}
if (!player.getInventory().remove(item, false)) {
return;
}
for (int id : set.getComponents()) {
player.getInventory().add(new Item(id, 1));
}
player.getInventory().refresh();
player.getPacketDispatch().sendMessage("You successfully traded your set for its component items!");
} else {
if (!player.getInventory().containItems(set.getComponents())) {
player.getPacketDispatch().sendMessage("You don't have the parts that make up this set.");
break;
}
for (int id : set.getComponents()) {
player.getInventory().remove(new Item(id, 1), false);
}
player.getInventory().add(item);
player.getInventory().refresh();
player.getPacketDispatch().sendMessage("You successfully traded your item components for a set!");
}
player.getAudioManager().send(new Audio(4044, 1, 1));
PacketRepository.send(ContainerPacket.class, new ContainerContext(player, -1, -2, player.getAttribute("container-key", 93), player.getInventory(), false));
break;
case 155:
player.getPacketDispatch().sendMessage((String) CS2Mapping.forId(1089).getMap().get(set.getItemId()));
break;
}
}
/**
* Handles the main interface options.
* @param player The player.
* @param opcode The packet opcode.
* @param button The button id.
* @param slot The slot.
* @param itemId The item id.
* @return {@code true} if the option got handled.
*/
public boolean handleMainInterface(final Player player, int opcode, int button, int slot, int itemId) {
final GrandExchangeOffer offer = player.getGrandExchange().getTemporaryOffer();
final GrandExchangeOffer opened = player.getGrandExchange().getOpenedOffer();
int amount = offer == null ? 0 : offer.getAmount();
switch (button) {
case 209:
case 211:
if (opened == null) {
return false;
}
player.getGrandExchange().withdraw(opened, (button - 209) >> 1);
return true;
case 190:
player.getGrandExchange().confirmOffer();
return true;
case 194:
player.getGrandExchange().openSearch();
return true;
case 203:
if (opened == null) {
return false;
}
player.getGrandExchange().abort(opened.getIndex());
return true;
case 18:
case 34:
case 50:
case 69:
case 88:
case 107:
if (opcode == 205) {
player.getGrandExchange().abort((button - 18) >> 4);
return true;
}
player.getGrandExchange().view((button - 18) >> 4);
return true;
case 30:
case 46:
case 62:
case 81:
case 100:
case 119:
player.getGrandExchange().openBuy((button - 30) >> 4);
return true;
case 31:
case 47:
case 63:
case 82:
case 101:
case 120:
player.getGrandExchange().openSell((button - 31) >> 4);
return true;
case 157: // -1
setOfferAmount(player, offer, amount - 1);
return true;
case 159: // +1
setOfferAmount(player, offer, amount + 1);
return true;
case 162: // 1
setOfferAmount(player, offer, offer != null && offer.isSell() ? 1 : amount + 1);
return true;
case 164: // 10
setOfferAmount(player, offer, offer != null && offer.isSell() ? 10 : amount + 10);
return true;
case 166: // 100
setOfferAmount(player, offer, offer != null && offer.isSell() ? 100 : amount + 100);
return true;
case 168: // 1000 / sell all
if (offer != null && offer.isSell()) {
setOfferAmount(player, offer, GrandExchange.getInventoryAmount(player, offer.getItemId()));
return true;
}
setOfferAmount(player, offer, amount + 1000);
return true;
case 170: // value x
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
if (player.getInterfaceManager().getChatbox().getId() == 389) {
player.getGrandExchange().openSearch();
}
setOfferAmount(player, offer, (int) value);
return true;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount.");
return false;
case 180:
if (offer != null) {
setOfferValue(player, offer, offer.getEntry().getValue());
return true;
}
return false;
case 177: // mid - 5% value
case 183: // mid + 5% value
if (offer != null) {
setOfferValue(player, offer, (int) (offer.getEntry().getValue() * (button == 177 ? 0.95 : 1.05)));
return true;
}
return false;
case 171: // Decrease value by 1
case 173: // Increase value with 1
if (offer != null) {
setOfferValue(player, offer, offer.getOfferedValue() + (button == 171 ? -1 : 1));
return true;
}
return false;
case 185: // Set value x
if (offer == null) {
player.getPacketDispatch().sendMessage("Please select an offer first.");
return true;
}
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
if (player.getInterfaceManager().getChatbox().getId() == 389) {
player.getGrandExchange().openSearch();
}
setOfferValue(player, offer, (int) value);
return true;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount.");
return false;
case 195:
player.getInterfaceManager().close();
return true;
case 127:
player.getGrandExchange().setTemporaryOffer(null);
player.getInterfaceManager().closeSingleTab();
player.getInterfaceManager().closeChatbox();
return true;
}
return false;
}
/***
* Method used to handle the guide price opcode.
* @param player the player.
* @param opcode the opcode.
* @param buttonId the buttonId.
* @param slot the slot.
* @param itemId the itemId.
*/
private void handleGuidePrice(final Player player, final int opcode, final int buttonId, final int slot, final int itemId) {
switch (opcode) {
case 155:
GEGuidePrice.GuideType type = player.getAttribute("guide-price", null);
if (type == null) {
return;
}
int subtract = 0;
if (buttonId >= 15 && buttonId <= 23) {
subtract = 15;
}
if (buttonId >= 43 && buttonId <= 57) {
subtract = 43;
}
if (buttonId >= 89 && buttonId <= 103) {
subtract = 89;
}
if (buttonId >= 135 && buttonId <= 144) {
subtract = 135;
}
if (buttonId >= 167 && buttonId <= 182) {
subtract = 167;
}
player.getPacketDispatch().sendMessage(ItemDefinition.forId(type.getItems()[buttonId - subtract].getItem()).getExamine());
break;
}
}
}

View file

@ -0,0 +1,44 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.grave.GraveType;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the component plugin used for the grave purchasing interface.
* @author Vexia
*/
@InitializablePlugin
public final class GravePurchaseInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(652, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
if (slot == -1) {
return true;
}
final GraveType grave = GraveType.values()[slot];
int cost = grave.getCost();
if (!player.getInventory().containsItem(new Item(995, cost))) {
return true;
}
if (!player.getInventory().remove(new Item(995, cost)) && grave != GraveType.MEMORIAL_PLAQUE) {
player.getPacketDispatch().sendMessage("You don't have enough coins to buy this grave stone.");
return true;
}
player.getGraveManager().setType(grave);
player.getDialogueInterpreter().sendDialogue("Your gravestone has been changed as you requested.");
player.getInterfaceManager().close();
return true;
}
}

View file

@ -0,0 +1,213 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.repository.Repository;
import org.crandor.game.world.update.flag.player.AppearanceFlag;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle the interface of changing hairs.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class HairInterfacePlugin extends ComponentPlugin {
/**
* Represents the coins item.
*/
private static final Item COINS = new Item(995, 1000);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(204, this);
ComponentDefinition.put(203, this);
ComponentDefinition.put(199, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
handle(player, button, component.getId() == 204 ? true : false, component.getId() == 199 ? new int[] { 1, 2 } : new int[] { 1 });
return true;
}
/**
* Represents the method used to handle the buttons.
* @param player the player.
* @param button the button,
* @param male the male.
*/
public static void handle(final Player player, int button, boolean male, int... inter) {
if (inter != null && inter.length == 2) {
int style = -1;
int col = -1;
switch (button) {
case 139:
style = 11;
break;
case 140:
style = 10;
break;
case 141:
style = 13;
break;
case 142:
style = 15;
break;
case 143:
style = 17;
break;
case 144:
style = 12;
break;
case 145:
style = 14;
break;
case 146:
style = 16;
break;
case 127:
col = 0;
break;
case 128:
col = 1;
break;
case 129:
col = 2;
break;
case 130:
col = 3;
break;
case 131:
col = 4;
break;
case 132:
col = 5;
break;
case 133:
col = 6;
break;
case 134:
col = 7;
break;
case 135:
col = 8;
break;
case 136:
col = 9;
break;
case 137:
col = 10;
break;
case 138:
col = 11;
break;
case 104:
confirm(player);
/** confirms the players choice on design. */
break;
}
if (style != -1) {
player.setAttribute("newBeard", style);
}
if (col != -1) {
player.setAttribute("newHairColour", col);
}
return;
}
if (male) {
switch (button) {
case 134:
case 135:
case 136:
case 137:
case 138:
case 139:
case 140:
case 141:
case 142:
player.setAttribute("newHair", button - 134);
break;
case 122:
case 123:
case 124:
case 125:
case 126:
case 127:
case 128:
case 129:
case 130:
case 131:
case 132:
case 133:
player.setAttribute("newHairColour", button - 122);
break;
case 98:
confirm(player);
break;
}
} else {
switch (button) {
case 136:
case 137:
case 138:
case 139:
case 140:
case 141:
case 142:
case 143:
case 144:
case 145:
player.setAttribute("newHair", button - 91);
break;
case 124:
case 125:
case 126:
case 127:
case 128:
case 129:
case 130:
case 131:
case 132:
case 133:
case 134:
case 135:
player.setAttribute("newHairColour", button - 124);
break;
case 99:
confirm(player);
break;
}
}
}
/**
* The accepting of your new style.
* @param player the player.
*/
public static void confirm(Player player) {
if (!player.getInventory().containsItem(COINS)) {
return;
}
if (player.getInventory().remove(COINS)) {
if (player.getAttribute("newHair") != null) {
player.getAppearance().getHair().changeLook((Integer) player.getAttribute("newHair"));
}
if (player.getAttribute("newHairColour") != null) {
player.getAppearance().getHair().changeColor((Integer) player.getAttribute("newHairColour"));
}
if (player.getAttribute("newBeard") != null) {
player.getAppearance().getBeard().changeLook((Integer) player.getAttribute("newBeard"));
}
player.getUpdateMasks().register(new AppearanceFlag(player));
player.getInterfaceManager().close();
player.getDialogueInterpreter().sendDialogues(Repository.findNPC(598), null, "Hope you like the new do!");
}
}
}

View file

@ -0,0 +1,199 @@
package plugin.interaction.inter;
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.free.crafting.jewellery.JewelleryCrafting;
import org.crandor.game.content.skill.free.crafting.jewellery.JewelleryCrafting.JewelleryItem;
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.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.StringUtils;
/**
* Represents the interface plugin used for jewellery crafting.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class JewelleryInterface extends ComponentPlugin {
/**
* Represents constants of useful items.
*/
public static final int RING_MOULD = 1592, AMULET_MOULD = 1595, NECKLACE_MOULD = 1597, BRACELET_MOULD = 11065, GOLD_BAR = 2357, SAPPHIRE = 1607, EMERALD = 1605, RUBY = 1603, DIAMOND = 1601, DRAGONSTONE = 1615, ONYX = 6573;
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(446, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
int amount = 0;
JewelleryCrafting.JewelleryItem data = null;
switch(button){
case 20:
data = JewelleryItem.GOLD_RING;
break;
case 22:
data = JewelleryItem.SAPPIRE_RING;
break;
case 24:
data = JewelleryItem.EMERALD_RING;
break;
case 26:
data = JewelleryItem.RUBY_RING;
break;
case 28:
data = JewelleryItem.DIAMOND_RING;
break;
case 30:
data = JewelleryItem.DRAGONSTONE_RING;
break;
case 32:
data = JewelleryItem.ONYX_RING;
break;
case 35:
data = JewelleryItem.SLAYER_RING;
break;
}
switch (button - 3) {
case 39:
data = JewelleryItem.GOLD_NECKLACE;
break;
case 41:
data = JewelleryItem.SAPPHIRE_NECKLACE;
break;
case 43:
data = JewelleryItem.EMERALD_NECKLACE;
break;
case 45:
data = JewelleryItem.RUBY_NECKLACE;
break;
case 47:
data = JewelleryItem.DIAMOND_NECKLACE;
break;
case 49:
data = JewelleryItem.DRAGONSTONE_NECKLACE;
break;
case 51:
data = JewelleryItem.ONYX_NECKLACE;
break;
case 58:
data = JewelleryItem.GOLD_AMULET;
break;
case 60:
data = JewelleryItem.SAPPHIRE_AMULET;
break;
case 62:
data = JewelleryItem.EMERALD_AMULET;
break;
case 64:
data = JewelleryItem.RUBY_AMULET;
break;
case 66:
data = JewelleryItem.DIAMOND_AMULET;
break;
case 68:
data = JewelleryItem.DRAGONSTONE_AMULET;
break;
case 70:
data = JewelleryItem.ONYX_AMULET;
break;
case 77:
data = JewelleryItem.GOLD_BRACELET;
break;
case 79:
data = JewelleryItem.SAPPHIRE_BRACELET;
break;
case 81:
data = JewelleryItem.EMERALD_BRACELET;
break;
case 83:
data = JewelleryItem.RUBY_BRACELET;
break;
case 85:
data = JewelleryItem.DIAMOND_BRACELET;
break;
case 87:
data = JewelleryItem.DRAGONSTONE_BRACELET;
break;
case 89:
data = JewelleryItem.ONYX_BRACELET;
break;
}
if (data == null) {
return true;
}
if (player.getSkills().getLevel(Skills.CRAFTING) < data.getLevel()) {
String an = StringUtils.isPlusN(ItemDefinition.forId(data.getSendItem()).getName().toLowerCase()) ? "an" : "a";
player.getPacketDispatch().sendMessage("You need a crafting level of " + data.getLevel() + " to craft " + an + " " + ItemDefinition.forId(data.getSendItem()).getName().toLowerCase() + ".");
return true;
}
String name = ItemDefinition.forId(data.getSendItem()).getName().toLowerCase();
boolean flag = false;
if (name.contains("ring") && !player.getInventory().contains(RING_MOULD, 1)) {
flag = true;
}
if (name.contains("necklace") && !player.getInventory().contains(NECKLACE_MOULD, 1)) {
flag = true;
}
if (name.contains("amulet") && !player.getInventory().contains(AMULET_MOULD, 1)) {
flag = true;
}
if (name.contains("bracelet") && !player.getInventory().contains(BRACELET_MOULD, 1)) {
flag = true;
}
if (flag) {
player.getPacketDispatch().sendMessage("You don't have the required mould to make this.");
return flag;
}
switch (opcode) {
case 155:
amount = 1;
break;
case 196:
amount = 5;
break;
case 124:
if (data.name().contains("GOLD")) {
amount = player.getInventory().getAmount(new Item(GOLD_BAR));
} else {
int first = player.getInventory().getAmount(new Item(data.getItems()[0]));
int second = player.getInventory().getAmount(new Item(data.getItems()[1]));
if (first == second) {
amount = first;
} else if (first > second) {
amount = second;
} else {
amount = first;
}
}
break;
case 199:
final JewelleryItem d = data;
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
JewelleryCrafting.make(player, d, (int) getValue());
return true;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter amount:");
return true;
}
if(!player.getSlayer().getLearned()[1] && data.equals(JewelleryItem.SLAYER_RING)){
player.sendMessages("You don't know how to make this. Talk to any Slayer master in order to learn the", "ability that creates Slayer rings.");
return true;
}
JewelleryCrafting.make(player, data, amount);
return true;
}
}

View file

@ -0,0 +1,59 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.skill.free.crafting.armour.LeatherCrafting;
import org.crandor.game.content.skill.free.crafting.armour.SoftCraftPulse;
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.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the leather crafting interface.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class LeatherCraftInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(154, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
int amount = 0;
final LeatherCrafting.SoftLeather soft = LeatherCrafting.SoftLeather.forButton(button);
if (soft == null) {
return true;
}
switch (opcode) {
case 155:
amount = 1;
break;
case 196:
amount = 5;
break;
case 124:
amount = player.getInventory().getAmount(new Item(LeatherCrafting.LEATHER));
break;
case 199:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
player.getPulseManager().run(new SoftCraftPulse(player, new Item(LeatherCrafting.LEATHER), soft, (int) getValue()));
return true;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter amount:");
return true;
}
player.getPulseManager().run(new SoftCraftPulse(player, null, soft, amount));
return true;
}
}

View file

@ -0,0 +1,42 @@
package plugin.interaction.inter;
import org.crandor.game.content.skill.free.crafting.armour.LeatherCrafting;
import org.crandor.game.content.skill.free.crafting.armour.LeatherCrafting.SoftLeather;
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 for crafting leather.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class LeatherCraftPlugin extends UseWithHandler {
/**
* Constructs a new {@code LeatherCraftPlugin} {@code Object}.
*/
public LeatherCraftPlugin() {
super(LeatherCrafting.LEATHER, LeatherCrafting.HARD_LEATHER, LeatherCrafting.GREEN_LEATHER, LeatherCrafting.BLUE_LEATHER, LeatherCrafting.RED_LEATHER, LeatherCrafting.BLACK_LEATHER);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(LeatherCrafting.NEEDLE, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
if (event.getBaseItem().getId() == LeatherCrafting.LEATHER || event.getUsedItem().getId() == LeatherCrafting.LEATHER) {
SoftLeather.open(event.getPlayer());
} else if (event.getBaseItem().getId() == LeatherCrafting.HARD_LEATHER || event.getUsedItem().getId() == LeatherCrafting.HARD_LEATHER) {
event.getPlayer().getDialogueInterpreter().open(48923, "hard");
} else {
event.getPlayer().getDialogueInterpreter().open(48923, "dragon", event.getUsedItem().getId());
}
return true;
}
}

View file

@ -0,0 +1,51 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.info.login.LoginConfiguration;
import org.crandor.game.system.task.Pulse;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used for the login interface.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class LoginInterfacePlugin extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(378, this);
return null;
}
@Override
public boolean handle(final Player player, Component component, int opcode, int button, int slot, int itemId) {
switch (button) {
case 140:
if (player.getLocks().isLocked("login")) {
return true;
}
player.getLocks().lock("login", 2);
player.getInterfaceManager().close();
player.getPulseManager().run(new Pulse(1) {
@Override
public boolean pulse() {
LoginConfiguration.configureGameWorld(player);
return true;
}
});
break;
case 145://credits
break;
case 204://message centre
break;
}
return true;
}
}

View file

@ -0,0 +1,40 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.world.GameWorld;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the interface used to logout of the game.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class LogoutInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(182, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
if (!player.getZoneMonitor().canLogout()) {
return true;
}
if (player.inCombat()) {
player.getPacketDispatch().sendMessage("You can't log out until 10 seconds after the end of combat.");
return true;
}
if (player.getAttribute("logoutDelay", 0) < GameWorld.getTicks()) {
player.getPacketDispatch().sendLogout();
player.setAttribute("logoutDelay", GameWorld.getTicks() + 3);
}
return true;
}
}

View file

@ -0,0 +1,36 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.skill.free.magic.MagicSpell;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.SpellBookManager.SpellBook;
import org.crandor.game.world.GameWorld;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the magic book interface handling of non-combat spells.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class MagicBookInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(192, this);
ComponentDefinition.put(193, this);
ComponentDefinition.put(430, this);
return this;
}
@Override
public boolean handle(final Player player, Component component, int opcode, int button, int slot, int itemId) {
if (GameWorld.getTicks() < player.getAttribute("magic:delay", -1)) {
return true;
}
return MagicSpell.castSpell(player, component.getId() == 192 ? SpellBook.MODERN : component.getId() == 193 ? SpellBook.ANCIENT : SpellBook.LUNAR, button, player);
}
}

View file

@ -0,0 +1,104 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.appearance.Gender;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.repository.Repository;
import org.crandor.game.world.update.flag.player.AppearanceFlag;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the interface used to handle the buttons related to the make over
* mage interface.
* @author 'Vexia
* @date 26/12/2013
*/
@InitializablePlugin
public class MakeOverInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(205, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
handle(player, button);
return true;
}
/**
* Method used to confirm the order.
* @param player the player.
*/
public static void confirm(Player player) {
boolean male = player.getAttribute("design:male", player.getAppearance().isMale());
int skin = player.getAttribute("design:skin", player.getAppearance().getSkin().getColor());
if (!player.getInventory().containsItem(new Item(995, 3000))) {
return;
}
if (skin != -1 && player.getInventory().remove(new Item(995, 3000))) {
Gender g = male ? Gender.MALE : Gender.FEMALE;
if (g != player.getAppearance().getGender()) {
player.getAppearance().changeGender(g);
}
player.getAppearance().getSkin().changeColor(skin);
player.getUpdateMasks().register(new AppearanceFlag(player));
player.getInterfaceManager().close();
player.removeAttribute("design:male");
player.removeAttribute("design:skin");
player.getDialogueInterpreter().open(2676, Repository.findNPC(2676), 1);
}
}
/**
* Method used to handle the buttons.
* @param player the player.
* @param button the button.
*/
public static void handle(Player player, int button) {
int skin = 0;
switch (button) {
case 113:
player.setAttribute("design:male", false);
break;
case 112:
player.setAttribute("design:male", true);
break;
case 100:
skin = 7;
break;
case 93:
skin = 1;
break;
case 94:
skin = 2;
break;
case 95:
break;
case 96:
skin = 3;
break;
case 97:
skin = 4;
break;
case 98:
skin = 5;
break;
case 99:
skin = 6;
break;
case 88:
confirm(player);
break;
}
if (button != 88 && button != 112 && button != 113) {
player.setAttribute("design:skin", skin);
}
}
}

View file

@ -0,0 +1,46 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.music.MusicEntry;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the interface tab buttons.
* @author Emperor
*/
@InitializablePlugin
public final class MusicTabInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(187, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
switch (opcode) {
case 155:
switch (button) {
case 11:
player.getMusicPlayer().toggleLooping();
return true;
case 1:
MusicEntry entry = player.getMusicPlayer().getUnlocked().get(slot);
if (entry == null) {
player.getPacketDispatch().sendMessage("You have not unlocked this piece of music yet!</col>");
return true;
}
player.getMusicPlayer().play(entry);
return true;
}
break;
}
return false;
}
}

View file

@ -0,0 +1,181 @@
package plugin.interaction.inter;
import org.crandor.ServerConstants;
import org.crandor.cache.def.impl.ObjectDefinition;
import org.crandor.game.component.CloseEvent;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
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.map.Location;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.PluginManager;
/**
* Handles an orb viewing interface.
* @author 'Vexia
* @author Emperor
* @version 1.0
*/
@InitializablePlugin
public final class OrbViewingInterface extends ComponentPlugin {
/*
* Order: South-west, South-east, North-west, North-east, Centre
*/
/**
* The fight pit locations.
*/
private static final Location[] FIGHT_PITS = { Location.create(2388, 5138, 0), Location.create(2411, 5137, 0), Location.create(2409, 5158, 0), Location.create(2384, 5157, 0), Location.create(2398, 5150, 0) };
/**
* The clan war locations.
*/
private static final Location[] CLAN_WARS = { Location.create(3277, 3725, 0), Location.create(3315, 3725, 0), Location.create(3316, 3829, 0), Location.create(3277, 3827, 0), Location.create(3296, 3776, 0) };
/**
* The bounty hunter viewing orb locations.
*/
private static final Location[][] BOUNTY_HUNTER = { { // Low level crater
Location.create(2752, 5695, 0), Location.create(2816, 5695, 0), Location.create(2783, 5783, 0), Location.create(2826, 5785, 0), Location.create(2784, 5727, 0) }, { // Mid
// level
// crater
Location.create(3008, 5695, 0), Location.create(3072, 5695, 0), Location.create(3039, 5783, 0), Location.create(3082, 5785, 0), Location.create(3040, 5727, 0) }, { // High
// level
// crater
Location.create(3264, 5695, 0), Location.create(3328, 5695, 0), Location.create(3295, 5783, 0), Location.create(3338, 5785, 0), Location.create(3296, 5727, 0) } };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(374, this);
ComponentDefinition.put(649, this);
PluginManager.definePlugin(new OptionHandler() {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.forId(9391).getConfigurations().put("option:look-into", this);
ObjectDefinition.forId(28194).getConfigurations().put("option:look-into", this);
ObjectDefinition.forId(28209).getConfigurations().put("option:view", this);
ObjectDefinition.forId(28210).getConfigurations().put("option:view", this);
ObjectDefinition.forId(28211).getConfigurations().put("option:view", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
int interfaceId = 649;
switch (node.getId()) {
case 9391:
interfaceId = 374;
player.setAttribute("viewing_orb", FIGHT_PITS);
break;
case 28194:
player.setAttribute("viewing_orb", CLAN_WARS);
break;
case 28209:
case 28210:
case 28211:
player.setAttribute("viewing_orb", BOUNTY_HUNTER[node.getId() - 28209]);
break;
}
viewOrb(player, interfaceId);
return true;
}
@Override
public Location getDestination(Node node, Node n) {
switch (n.getId()) {
case 28194:
return n.getLocation().transform(1, 0, 0);
}
return null;
}
});
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
Location[] locations = player.getAttribute("viewing_orb");
if (locations == null) {
return false;
}
if (button != 5) {
move(player, locations[15 - button]);
} else {
stopViewing(player, true);
}
return true;
}
/**
* Method used to move to a viewing location.
* @param location the location.
*/
private void move(final Player player, final Location location) {
player.getLocks().lockMovement(100000000);
player.getProperties().setTeleportLocation(location);
if (player.getAppearance().getNpcId() == -1) {
player.getAppearance().transformNPC(-2);
player.getAppearance().sync();
}
}
/**
* Views an orb.
* @param player the player.
* @param interfaceId the interface id.
*/
private void viewOrb(final Player player, final int interfaceId) {
final Component component = new Component(interfaceId).setCloseEvent(new ViewCloseEvent());
player.setAttribute("view-location", player.getLocation());
player.getInterfaceManager().openSingleTab(component);
player.getPulseManager().run(new Pulse(1, player) {
@Override
public boolean pulse() {
return false;
}
@Override
public void stop() {
super.stop();
stopViewing(player, true);
}
});
}
/**
* Ends the viewing session.
* @param player the player.
* @param close if we should close the interface.
*/
private static void stopViewing(final Player player, boolean close) {
if (close) {
player.getInterfaceManager().closeSingleTab();
}
player.removeAttribute("viewing_orb");
player.unlock();
player.getAppearance().transformNPC(-1);
player.getAppearance().sync();
player.getPulseManager().clear();
player.getProperties().setTeleportLocation(player.getAttribute("view-location", ServerConstants.HOME_LOCATION));
}
/**
* Handles the close event of a viewing interface.
* @author 'Vexia
*/
public static final class ViewCloseEvent implements CloseEvent {
@Override
public boolean close(Player player, Component c) {
stopViewing(player, false);
return true;
}
}
}

View file

@ -0,0 +1,63 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
import org.crandor.tools.StringUtils;
/**
* Package -> plugin.interaction.inter
* Created on -> 9/6/2016 @8:12 PM for 530
*
* @author Ethan Kyle Millard
*/
@InitializablePlugin
public class PlayerExamineInterfacePlugin extends ComponentPlugin {
private Player node;
public PlayerExamineInterfacePlugin() {
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(31, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
switch (button) {
case 2:
component.close(player);
break;
}
return true;
}
public void prepareInterface(Player player, Player examined) {
Component component = new Component(31);
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 7, true);
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 8, true);
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 15, true);
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 18, true);
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 2, true);
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 14, true);
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 13, true);
player.getInterfaceManager().open(component);
player.getPacketDispatch().sendString("<col=" + examined.getSavedData().getSpawnData().getTitle().getTitleColor() + ">" + examined.getSavedData().getSpawnData().getTitle().getName() + "</col> " + StringUtils.formatDisplayName(examined.getName()) + " - Combat Level: " + player.getProperties().getCurrentCombatLevel(), 31, 3);
player.getPacketDispatch().sendString("KDR -> ", 31, 9);
player.getPacketDispatch().sendString("Total Kills -> ", 31, 10);
player.getPacketDispatch().sendString("Total Deaths -> ", 31, 16);
player.getPacketDispatch().sendString("Killstreak -> ", 31, 19);
player.getPacketDispatch().sendString("" + examined.getSavedData().getSpawnData().getKdr(), 31, 11);
player.getPacketDispatch().sendString("" + examined.getSavedData().getSpawnData().getKills(), 31, 12);
player.getPacketDispatch().sendString("" + examined.getSavedData().getSpawnData().getDeaths(), 31, 17);
player.getPacketDispatch().sendString("" + examined.getSavedData().getSpawnData().getKillStreak(), 31, 20);
player.getPacketDispatch().sendString("Close", 31, 5);
}
}

View file

@ -0,0 +1,33 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.prayer.PrayerType;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the prayer interface.
* @author 'Vexia
*/
@InitializablePlugin
public final class PrayerTabInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(271, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
final PrayerType type = PrayerType.get(button);
if (type == null) {
return true;
}
player.getPrayer().toggle(type);
return true;
}
}

View file

@ -0,0 +1,42 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.RandomFunction;
/**
* Represents the puppy interface plugin.
* @author 'Vexia
*/
@InitializablePlugin
public final class PuppyInterfacePlugin extends ComponentPlugin {
/**
* Represents the names of the puppys.
*/
private static final String[] NAMES = new String[] { "labrador", "bulldog", "dalmatian", "greyhound", "terrier", "sheepdog" };
/**
* Represents the puppies.
*/
private static final Item[][] PUPPIES = new Item[][] { { new Item(12516), new Item(12708), new Item(12710) }, { new Item(12522), new Item(12720), new Item(12722) }, { new Item(12518), new Item(12712), new Item(12714) }, { new Item(12514), new Item(12704), new Item(12706) }, { new Item(12512), new Item(12700), new Item(12702) }, { new Item(12520), new Item(12716), new Item(12718) } };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(668, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
int index = button == 3 ? 1 : button == 8 ? 0 : button == 6 ? 1 : button == 4 ? 2 : button == 5 ? 3 : button == 6 ? 4 : 5;
player.getDialogueInterpreter().open(6893, NAMES[index], PUPPIES[index][RandomFunction.random(PUPPIES[index].length)]);
return true;
}
}

View file

@ -0,0 +1,74 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.global.tutorial.TutorialSession;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.diary.AchievementDiary;
import org.crandor.game.node.entity.player.link.diary.DiaryType;
import org.crandor.game.node.entity.player.link.quest.Quest;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the quest tab reward buttons.
* @author Emperor
* @author Vexia
*/
@InitializablePlugin
public class QuestTabInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(274, this); // Quests
ComponentDefinition.put(259, this); // Achievement diary
return this;
}
@Override
public boolean handle(Player p, Component component, int opcode, int button, int slot, int itemId) {
if (TutorialSession.getExtension(p).getStage() < TutorialSession.MAX_STAGE) {
return true;
}
p.getPulseManager().clear();
switch (component.getId()) {
case 274:
// if (!GameWorld.isEconomyWorld()) {
// p.getSavedData().getSpawnData().handleButton(p, button);
// }
switch (button) {
case 3:
p.getAchievementDiaryManager().openTab();
return true;
case 10:
break;
default:
// if (GameWorld.isEconomyWorld()) {
Quest quest = p.getQuestRepository().forButtonId(button);
if (quest != null) {
p.getInterfaceManager().open(new Component(275));
quest.drawJournal(p, quest.getStage(p));
return true;
}
// }
return false;
}
break;
case 259:
switch (button) {
case 8:
p.getInterfaceManager().openTab(2, new Component(274));
return true;
default:
AchievementDiary diary = p.getAchievementDiaryManager().getDiary(DiaryType.forChild(button));
if (diary != null) {
diary.open(p);
}
return true;
}
}
return true;
}
}

View file

@ -0,0 +1,65 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.request.assist.AssistSession;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* @author 'Vexia
*/
@InitializablePlugin
public class RequestAssistInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(301, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
final AssistSession session = AssistSession.getExtension(player);
if (session == null) {
return true;
}
if (player != session.getPlayer()) {
return true;
}
switch (button) {
case 15:
session.toggleButton((byte) 0);
break;
case 20:
session.toggleButton((byte) 1);
break;
case 25:
session.toggleButton((byte) 2);
break;
case 30:
session.toggleButton((byte) 3);
break;
case 35:
session.toggleButton((byte) 4);
break;
case 40:
session.toggleButton((byte) 5);
break;
case 45:
session.toggleButton((byte) 6);
break;
case 50:
session.toggleButton((byte) 7);
break;
case 55:
session.toggleButton((byte) 8);
break;
}
session.refresh();
return true;
}
}

View file

@ -0,0 +1,175 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.game.node.entity.player.link.diary.DiaryType;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the component handler for the interface 403.
* @author 'Vexia
* @date Oct 8, 2013
*/
@InitializablePlugin
public class SawmillPlankInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(403, this);
return this;
}
@Override
public boolean handle(final Player player, Component component, int opcode, int button, int slot, int itemId) {
Plank plank = null;
if (button > 101 && button < 108) {
plank = Plank.WOOD;
} else if (button > 108 && button < 114) {
plank = Plank.OAK;
} else if (button > 114 && button < 120) {
plank = Plank.TEAK;
} else if (button > 120 && button < 126) {
plank = Plank.MAHOGANY;
}
int amount = -1;
int fullIndex = plank == Plank.WOOD ? 107 : plank == Plank.OAK ? 113 : plank == Plank.TEAK ? 119 : 125;
// 107, 105, 104, 103, 102
int difference = -1;
if (plank != Plank.WOOD) {
difference = fullIndex - button;
} else {
difference = fullIndex - button - (button != 107 ? 1 : 0);
}
switch (difference) {
case 0:
amount = 1;
break;
case 1:
amount = 5;
break;
case 2:
amount = 10;
break;
case 3:
amount = 69;
break;
case 4:
amount = player.getInventory().getAmount(plank.getLog());
break;
}
if (amount == 69) {
final Plank plankk = plank;
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
create(player, plankk, (int) super.getValue());
return true;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
return true;
}
if (plank != null) {
create(player, plank, amount);
}
return true;
}
/**
* Method used to create a plank from a log.
* @param player the player.
* @param plank the plank.
* @param amount the amount.
*/
public final void create(final Player player, final Plank plank, int amount) {
player.getInterfaceManager().close();
if (amount > player.getInventory().getAmount(plank.getLog())) {
amount = player.getInventory().getAmount(plank.getLog());
}
if (!player.getInventory().containsItem(new Item(plank.getLog().getId()))) {
player.getDialogueInterpreter().sendDialogues(4250, null, "You'll need to bring me some more logs.");
return;
}
if (!player.getInventory().contains(995, plank.getPrice() * amount)) {
player.getDialogueInterpreter().sendDialogues(player, null, "Sorry, I don't have enough coins to pay for that.");
return;
}
if (player.getInventory().remove(new Item(995, plank.getPrice() * amount))) {
if (plank == Plank.WOOD && !player.getAchievementDiaryManager().getDiary(DiaryType.VARROCK).isComplete(0, 3)) {
player.getAchievementDiaryManager().getDiary(DiaryType.VARROCK).updateTask(player, 0, 3, true);
}
if (plank == Plank.MAHOGANY && amount == 20 && !player.getAchievementDiaryManager().getDiary(DiaryType.VARROCK).isComplete(1, 6)) {
player.getAchievementDiaryManager().getDiary(DiaryType.VARROCK).updateTask(player, 1, 6, true);
}
Item remove = plank.getLog();
remove.setAmount(amount);
if (player.getInventory().remove(remove)) {
Item planks = plank.getPlank();
planks.setAmount(amount);
player.getInventory().add(planks);
}
}
}
/**
* Represents an enum of planks to be boughten.
* @author 'Vexia
* @date Oct 8, 2013
*/
public enum Plank {
WOOD(new Item(1511), new Item(960), 100), OAK(new Item(1521), new Item(8778), 250), TEAK(new Item(6333), new Item(8780), 500), MAHOGANY(new Item(6332), new Item(8782), 1500);
/**
* Constructs a new {@code SawmillPlankInterface} {@code Object}.
* @param log the log.
* @param plank the plank.
* @param price the price.
*/
Plank(Item log, Item plank, int price) {
this.log = log;
this.plank = plank;
this.price = price;
}
/**
* Represents the item needed.
*/
private final Item log;
/**
* Represents the item given.
*/
private final Item plank;
/**
* Represents the price of the plank.
*/
private final int price;
/**
* @return the log.
*/
public Item getLog() {
return log;
}
/**
* @return the plank.
*/
public Item getPlank() {
return plank;
}
/**
* @return the price.
*/
public int getPrice() {
return price;
}
}
}

View file

@ -0,0 +1,91 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.global.tutorial.TutorialSession;
import org.crandor.game.content.global.tutorial.TutorialStage;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* @author 'Vexia
*/
@InitializablePlugin
public class SettingTabInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(261, this);
return this;
}
@Override
public boolean handle(Player p, Component component, int opcode, int button, int slot, int itemId) {
switch (button) {
case 10:// brightness
int brightness = button - 7;
p.getSettings().setBrightness(brightness);
break;
case 11:
case 12:
case 13:
case 14:
case 15:// music
int volume = 15 - button;
p.getSettings().setMusicVolume(volume);
break;
case 16://530 settings
p.getInterfaceManager().open(new Component(742));
break;
case 18://530 settings
p.getInterfaceManager().open(new Component(743));
break;
case 17:
case 19:
case 20:// sonund
int volume1 = 20 - button;
p.getSettings().setSoundEffectVolume(volume1);
break;
case 29:
case 30:
case 31:
case 32:
case 33:// all sound
int volume11 = 33 - button;
p.getSettings().setAreaSoundVolume(volume11);
break;
case 6:// mouse
p.getSettings().toggleMouseButton();
break;
case 4:// effects
p.getSettings().toggleChatEffects();
break;
case 5:// private chat
p.getSettings().toggleSplitPrivateChat();
break;
case 7:// aid
if (p.getIronmanManager().checkRestriction()) {
return true;
}
p.getSettings().toggleAcceptAid();
break;
case 3:// run
if (TutorialSession.getExtension(p).getStage() == 25) {
TutorialStage.load(p, 26, false);
}
p.getSettings().toggleRun();
break;
case 8:// house
if (!TutorialSession.getExtension(p).finished()) {
return true;
}
p.getInterfaceManager().close();
p.getConfigManager().set(261, p.getConfigManager().get(261) & 0x1);
p.getInterfaceManager().openSingleTab(new Component(398));
break;
}
return true;
}
}

View file

@ -0,0 +1,31 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.global.travel.ship.ShipCharter;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the chip chartering interface plugin.
* @author 'Vexia
* @date 28/11/2013
*/
@InitializablePlugin
public class ShipCharterInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(95, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
ShipCharter.handle(player, button);
return true;
}
}

View file

@ -0,0 +1,126 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.container.Container;
import org.crandor.game.content.global.shop.ShopViewer;
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.net.packet.in.ExaminePacket;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle the shopping interface.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class ShoppingPlugin extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.forId(620).setPlugin(this);
ComponentDefinition.forId(621).setPlugin(this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
final ShopViewer viewer = player.getExtension(ShopViewer.class);
if (viewer == null) {
return true;
}
final Container container = button == 0 ? player.getInventory() : viewer.getShop().getContainer(viewer.getTabIndex());
switch (opcode) {
case 155:
switch (button) {
case 23:
case 24:
case 0:
value(player, viewer, container.get(slot), component.getId() == 621);
break;
case 25:
case 26:
viewer.showStock(button == 26 ? 1 : 0);
break;
}
break;
case 9:
int id = container.getId(slot);
if (id == -1) {
return true;
}
player.getPacketDispatch().sendMessage(ExaminePacket.getItemExamine(id));
break;
case 196:
case 199:
case 124:
case 234:
final int amount = getAmount(opcode);
if (player.getAttribute("shop-delay", 0L) > System.currentTimeMillis()) {
return true;
}
player.setAttribute("shop-delay", System.currentTimeMillis() + 500);
if (amount == -1) {
player.setAttribute("runscript", getRunScript(viewer, slot, component.getId()));
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
break;
}
if (component.getId() == 620) {
viewer.getShop().buy(player, slot, amount, viewer.getTabIndex());
} else {
viewer.getShop().sell(player, slot, amount, viewer.getTabIndex());
}
break;
}
return true;
}
/**
* Method used to value an item.
* @param player the player.
* @param viewer the viewer.
* @param item the item.
* @param sell the sell.
*/
private void value(final Player player, final ShopViewer viewer, final Item item, final boolean sell) {
if (item == null) {
return;
}
viewer.getShop().value(player, viewer, item, sell);
}
/**
* Gets the run script for selling an item.
* @return the script.
* @param slot the slot.
*/
private RunScript getRunScript(final ShopViewer viewer, final int slot, final int componentId) {
return new RunScript() {
@Override
public boolean handle() {
switch (componentId){
case 620:
viewer.getShop().buy(viewer.getPlayer(), slot, (int) getValue(), viewer.getTabIndex());
break;
case 621:
viewer.getShop().sell(viewer.getPlayer(), slot, (int) getValue(), viewer.getTabIndex());
break;
}
return true;
}
};
}
/**
* Gets the amount by the opcode.
* @param opcode the opcode.
* @return the amount.
*/
private int getAmount(int opcode) {
return opcode == 196 ? 1 : opcode == 124 ? 5 : opcode == 199 ? 10 : -1;
}
}

View file

@ -0,0 +1,115 @@
package plugin.interaction.inter;
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.free.crafting.SilverProduct;
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.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;
/**
* Represents the silver crafting making interface.
* @author 'Vexia
*/
@InitializablePlugin
public final class SilverInterface extends ComponentPlugin {
/**
* Represents the silver bar item.
*/
private static final Item SILVER_BAR = new Item(2355);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(438, this);
return this;
}
@Override
public boolean handle(final Player p, Component component, int opcode, int button, int slot, int itemId) {
final SilverProduct silver = SilverProduct.forId(button);
if (silver == null) {
return true;
}
if (!p.getInventory().contains(silver.getNeeded(), 1)) {
p.getPacketDispatch().sendMessage("You need a " + ItemDefinition.forId(silver.getNeeded()).getName().toLowerCase() + " to make this item.");
return true;
}
if (silver == SilverProduct.SILVTHRIL_ROD) {
p.getPacketDispatch().sendMessage("You can't do that yet.");
return true;
}
if (p.getSkills().getLevel(Skills.CRAFTING) < silver.getLevel()) {
p.getPacketDispatch().sendMessage("You need a crafting level of " + silver.getLevel() + " to make this.");
}
int amt = -1;
switch (opcode) {
case 155:
amt = 1;
break;
case 196:
amt = 5;
break;
case 124:
amt = p.getInventory().getAmount(new Item(2355));
break;
case 199:
p.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int ammount = (int) value;
make(p, silver, ammount);
return true;
}
});
p.getDialogueInterpreter().sendInput(false, "Enter the amount.");
return true;
}
make(p, silver, amt);
return true;
}
private void make(final Player player, final SilverProduct def, final int ammount) {
if (!player.getInventory().containsItem(SILVER_BAR)) {
return;
}
player.getInterfaceManager().close();
GameWorld.submit(new Pulse(1, player) {
int amt = ammount;
@Override
public boolean pulse() {
if (amt < 1) {
return true;
}
if (!player.getInventory().contains(def.getNeeded(), 1)) {
return true;
}
if (player.getInventory().containsItem(SILVER_BAR) && player.getInventory().contains(def.getNeeded(), 1)) {
player.animate(new Animation(899));
if (player.getInventory().remove(SILVER_BAR)) {
player.getInventory().add(new Item(def.getProduct(), def == SilverProduct.SILVER_BOLTS ? 10 : 1));
player.getSkills().addExperience(Skills.CRAFTING, def.getExp(), true);
}
} else {
return true;
}
amt--;
return false;
}
@Override
public void stop() {
player.animate(new Animation(-1));
}
});
}
}

View file

@ -0,0 +1,29 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used for the skilling interface.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class SkillInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(499, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
player.getConfigManager().set(965, (Integer) player.getAttribute("skillMenu", -1) + (button - 10) * 1024);
return true;
}
}

View file

@ -0,0 +1,175 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.skill.LevelUp;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.game.world.GameWorld;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle the skilling tab.
* @author Vexia
* @author Splinter
* @version 1.1
*/
@InitializablePlugin
public final class SkillTabInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(320, this);
return this;
}
@Override
public boolean handle(Player p, Component component, int opcode, int button, int slot, int itemId) {
final SkillConfig config = SkillConfig.forId(button);
if (config == null) {
return true;
}
if (!GameWorld.getSettings().isPvp()) {
if (p.getAttribute("levelup:" + config.getSkillId(), false)) {
p.removeAttribute("levelup:" + config.getSkillId());
LevelUp.sendFlashingIcons(p, -1);
p.getConfigManager().set(1230, ADVANCE_CONFIGS[config.getSkillId()]);
p.getInterfaceManager().open(new Component(741));
} else {
p.getPulseManager().clear();
p.getInterfaceManager().open(new Component(499));
p.getConfigManager().set(965, config.getConfig());
p.getAttributes().put("skillMenu", config.getConfig());
}
} else {
if (config.getSkillId() > 6) {
p.getPacketDispatch().sendMessage("You cannot set a target level for this skill.");
return false;
}
if (!p.canSpawn()) {
p.sendMessage("You must be inside Edgeville bank to set levels.");
return false;
}
p.getDialogueInterpreter().sendInput(true, "Enter the target level: ");
p.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
final int target_level = Integer.parseInt((String) getValue());
if (target_level > 99 || target_level == -1) {
player.getPacketDispatch().sendMessage("Invalid target level.");
return true;
}
p.getSkills().setStaticLevel(config.getSkillId(), target_level);
p.getSkills().setLevel(config.getSkillId(), target_level);
return true;
}
});
}
return true;
}
/**
* Holds all the config values of the skill advances.
*/
public static final int[] ADVANCE_CONFIGS = {
9, 40, 17, 49,
25, 57, 33, 641,
659, 664, 121, 649,
89, 114, 107, 72,
64, 80, 673, 680,
99, 698, 689, 705,
};
public enum SkillConfig {
ATTACK(125, 1, Skills.ATTACK),
STRENGTH(126, 2, Skills.STRENGTH),
DEFENCE(127, 5, Skills.DEFENCE),
RANGE(128, 3, Skills.RANGE),
PRAYER(129, 7, Skills.PRAYER),
MAGIC(130, 4, Skills.MAGIC),
RUNECRAFTING(131, 12, Skills.RUNECRAFTING),
HITPOINTS(133, 6, Skills.HITPOINTS),
AGILITY(134, 8, Skills.AGILITY),
HERBLORE(135, 9, Skills.HERBLORE),
THIEVING(136, 10, Skills.THIEVING),
CRAFTING(137, 11, Skills.CRAFTING),
FLETCHING(138, 19, Skills.FLETCHING),
SLAYER(139, 20, Skills.SLAYER),
MINING(141, 13, Skills.MINING),
SMITHING(142, 14, Skills.SMITHING),
FISHING(143, 15, Skills.FISHING),
COOKING(144, 16, Skills.COOKING),
FIREMAKING(145, 17, Skills.FIREMAKING),
WOODCUTTING(146, 18, Skills.WOODCUTTING),
FARMING(147, 21, Skills.FARMING),
CONSTRUCTION(132, 22, Skills.CONSTRUCTION),
HUNTER(140, 23, Skills.HUNTER),
SUMMONING(148, 24, Skills.SUMMONING);
/**
* Constructs a new {@code SkillConfig} {@code Object}.
* @param button the button.
* @param config the config.
*/
SkillConfig(int button, int config, int skillId) {
this.button = button;
this.config = config;
this.skillId = skillId;
}
/**
* Represents the button.
*/
private int button;
/**
* Represents the config.
*/
private int config;
/**
* The skill id.
*/
private int skillId;
/**
* Gets the skill config.
* @param id the id.
* @return the skill config.
*/
public static SkillConfig forId(int id) {
for (SkillConfig config : SkillConfig.values()) {
if (config.button == id)
return config;
}
return null;
}
/**
* Gets the button.
* @return the button.
*/
public int getButton() {
return button;
}
/**
* Gets the config.
* @return the config.
*/
public int getConfig() {
return config;
}
/**
* Gets the skill id.
* @return The skill id.
*/
public int getSkillId() {
return skillId;
}
}
}

View file

@ -0,0 +1,115 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.skill.free.smithing.smelting.Bar;
import org.crandor.game.content.skill.free.smithing.smelting.SmeltingPulse;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* @author 'Vexia
*/
@InitializablePlugin
public class SmeltingInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(311, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
final BarButton barType = BarButton.forId(button);
if (barType == null) {
return true;
}
if (barType.getAmount() == -1) {
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int ammount = (int) value;
player.getPulseManager().run(new SmeltingPulse(player, null, barType.getBar(), ammount));
return false;
}
});
player.getInterfaceManager().closeChatbox();
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
} else {
player.getPulseManager().run(new SmeltingPulse(player, null, barType.getBar(), barType.getAmount()));
}
return true;
}
/**
* @author 'Vexia
*/
public enum BarButton {
BRONZE_1(16, Bar.BRONZE, 1), BRONZE_5(15, Bar.BRONZE, 5), BRONZE_10(14, Bar.BRONZE, 10), BRONZE_X(13, Bar.BRONZE, -1), BLURITE_1(20, Bar.BLURITE, 1), BLURITE_5(19, Bar.BLURITE, 5), BLURITE_10(18, Bar.BLURITE, 10), BLURITE_X(17, Bar.BLURITE, -1), IRON_1(24, Bar.IRON, 1), IRON_5(23, Bar.IRON, 5), IRON_10(22, Bar.IRON, 10), IRON_X(21, Bar.IRON, -1), SILVER_1(28, Bar.SILVER, 1), SILVER_5(27, Bar.SILVER, 5), SILVER_10(26, Bar.SILVER, 10), SILVER_X(25, Bar.SILVER, -1), STEEL_1(32, Bar.STEEL, 1), STEEL_5(31, Bar.STEEL, 5), STEEL_10(30, Bar.STEEL, 10), STEEL_X(29, Bar.STEEL, -1), GOLD_1(36, Bar.GOLD, 1), GOLD_5(35, Bar.GOLD, 5), GOLD_10(34, Bar.GOLD, 10), GOLD_X(33, Bar.GOLD, -1), MITHRIL_1(40, Bar.MITHRIL, 1), MITHRIL_5(39, Bar.MITHRIL, 5), MITHRIL_10(38, Bar.MITHRIL, 10), MITHRIL_X(37, Bar.MITHRIL, -1), ADAMANT_1(44, Bar.ADAMANT, 1), ADAMANT_5(43, Bar.ADAMANT, 5), ADAMANT_10(42, Bar.ADAMANT, 10), ADAMANT_X(41, Bar.ADAMANT, -1), RUNE_1(48, Bar.RUNITE, 1), RUNE_5(47, Bar.RUNITE, 5), RUNE_10(46, Bar.RUNITE, 10), RUNE_X(45, Bar.RUNITE, -1);
/**
* Constructs a new {@code BarButton} {@code Object}.
* @param button the button.
* @param bar the bar.
* @param amount the amt.
*/
BarButton(int button, Bar bar, int amount) {
this.button = button;
this.bar = bar;
this.amount = amount;
}
/**
* The button.
*/
private int button;
/**
* The bar.
*/
private Bar bar;
/**
* The ammount.
*/
private int amount;
/**
* @param id
* @return
*/
public static BarButton forId(int id) {
for (BarButton button : BarButton.values()) {
if (button.getButton() == id) {
return button;
}
}
return null;
}
/**
* @return the button.
*/
public int getButton() {
return button;
}
/**
* @return the bar.
*/
public Bar getBar() {
return bar;
}
/**
* @return the amount.
*/
public int getAmount() {
return amount;
}
}
}

View file

@ -0,0 +1,53 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.skill.free.smithing.BarType;
import org.crandor.game.content.skill.free.smithing.Bars;
import org.crandor.game.content.skill.free.smithing.SmithingPulse;
import org.crandor.game.content.skill.free.smithing.SmithingType;
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.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* @author 'Vexia
*/
@InitializablePlugin
public class SmithingInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(300, this);
return this;
}
@Override
public boolean handle(final Player p, Component component, int opcode, int button, int slot, int itemId) {
final int item = Bars.getItemId(button, (BarType) p.getGameAttributes().getAttribute("smith-type"));
final Bars bar = Bars.forId(item);
if (bar == null) {
return true;
}
int amount = SmithingType.forButton(p, bar, button, bar.getBarType().getBarType());
p.getGameAttributes().setAttribute("smith-bar", bar);
p.getGameAttributes().setAttribute("smith-item", item);
if (amount == -1) {
p.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
final int ammount = (int) value;
p.getPulseManager().run(new SmithingPulse(p, new Item((int) p.getGameAttributes().getAttribute("smith-item"), ammount), (Bars) p.getGameAttributes().getAttribute("smith-bar"), ammount));
return false;
}
});
p.getDialogueInterpreter().sendInput(false, "Enter the amount.");
return true;
}
p.getPulseManager().run(new SmithingPulse(p, new Item(item, amount), Bars.forId(item), amount));
return true;
}
}

View file

@ -0,0 +1,63 @@
package plugin.interaction.inter;
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.free.crafting.spinning.SpinningItem;
import org.crandor.game.content.skill.free.crafting.spinning.SpinningPulse;
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.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
@InitializablePlugin
public class SpinningInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(459, this);
return this;
}
@Override
public boolean handle(final Player p, Component component, int opcode, int button, int slot, int itemId) {
final SpinningItem spin = SpinningItem.forId(button);
if (spin == null) {
return true;
}
if (!p.getInventory().contains(spin.getNeed(), 1)) {
p.getPacketDispatch().sendMessage("You need "+ ItemDefinition.forId(spin.getNeed()).getName().toLowerCase() + " to make this.");
return true;
}
int amt = -1;
switch (opcode) {
case 155:
amt = 1;
break;
case 196:
amt = 5;
break;
case 124:
amt = p.getInventory().getAmount(new Item(spin.getNeed()));
break;
case 199:
p.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int ammount = (int) value;
p.getPulseManager().run(new SpinningPulse(p, new Item(spin.getNeed(), 1), ammount, spin));
return true;
}
});
p.getDialogueInterpreter().sendInput(false, "Enter the amount.");
break;
}
if (opcode == 199) {
return true;
}
p.getPulseManager().run(new SpinningPulse(p, new Item(spin.getNeed(), 1), amt, spin));
return true;
}
}

View file

@ -0,0 +1,94 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.content.skill.free.crafting.TanningProduct;
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.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* @author Vexia
* @version 1.2
*/
@InitializablePlugin
public class TanningInterface extends ComponentPlugin {
/**
* Method used to create a new instance.
* @param arg
* @return
* @throws Throwable
*/
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(324, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
TanningProduct def = null;
switch (button) {
case 1:
def = TanningProduct.SOFT_LEATHER;
break;
case 2:
def = TanningProduct.HARD_LEATHER;
break;
case 3:
def = TanningProduct.SNAKESKIN;
break;
case 4:
def = TanningProduct.SNAKESKIN2;
break;
case 5:
def = TanningProduct.GREEN_DHIDE;
break;
case 6:
def = TanningProduct.BLUEDHIDE;
break;
case 7:
def = TanningProduct.REDDHIDE;
break;
case 8:
def = TanningProduct.BLACKDHIDE;
break;
}
if (def == null) {
return true;
}
int amount = 0;
final TanningProduct deff = def;
switch (opcode){
case 155:
amount = 1;
break;
case 196:
amount = 5;
break;
case 124:
amount = 10;
case 199:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int amt = (int) getValue();
TanningProduct.tan(player, amt, deff);
return true;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter amount:");
break;
case 234:
amount = player.getInventory().getAmount(new Item(def.getItem(), 1));
break;
}
TanningProduct.tan(player, amount, def);
return true;
}
}

View file

@ -0,0 +1,245 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
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 interface plugin to handle thessalia interfaces.
* @author Vexia
* @version 1.0
*/
@InitializablePlugin
public final class ThessaliaInterface extends ComponentPlugin {
/**
* Represents the coins item.
*/
private static final Item COINS = new Item(995, 500);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(201, this);
ComponentDefinition.put(202, this);
ComponentDefinition.put(206, this);
ComponentDefinition.put(207, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
switch (component.getId()) {
case 207:
switch (button) {
case 157:
case 158:
player.setAttribute("newBody", button - 139);
break;
case 159:
case 161:
case 163:
player.setAttribute("newBody", button - 138);
break;
case 160:
case 162:
player.setAttribute("newBody", button - 140);
break;
case 164:
case 165:
case 166:
case 167:
case 168:
case 169:
player.setAttribute("newArms", button - 138);
break;
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
player.setAttribute("newBodyColour", button - 90);
break;
case 106:
if (!player.getInventory().containsItem(COINS)) {
return true;
}
if (player.getInventory().remove(COINS)) {
if (player.getAttribute("newBody") != null) {
player.getAppearance().getTorso().changeLook((Integer) player.getAttribute("newBody"));
}
if (player.getAttribute("newArms") != null) {
player.getAppearance().getArms().changeLook((Integer) player.getAttribute("newArms"));
}
if (player.getAttribute("newBodyColour") != null) {
player.getAppearance().getTorso().changeColor((Integer) player.getAttribute("newBodyColour"));
}
player.getAppearance().sync();
player.getInterfaceManager().close();
player.getDialogueInterpreter().open(548, true, true);
}
break;
}
break;
case 206:// male leg
switch (button) {
case 128:
case 129:
case 130:
case 131:
player.setAttribute("newLegs", button - 92);
break;
case 105:
player.setAttribute("newLegsColour", button - 105);
break;
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
player.setAttribute("newLegsColour", button - 89);
break;
case 106:
if (player.getInventory().remove(COINS)) {
if (player.getAttribute("newLegs") != null) {
player.getAppearance().getLegs().changeLook((Integer) player.getAttribute("newLegs"));
}
if (player.getAttribute("newLegsColour") != null) {
player.getAppearance().getLegs().changeColor((Integer) player.getAttribute("newLegsColour"));
}
player.getAppearance().sync();
player.getInterfaceManager().close();
player.getDialogueInterpreter().open(548, true, true);
}
break;
}
break;
case 202:
switch (button) {
case 146:
case 147:
case 148:
case 149:
case 150:
player.setAttribute("newBody", button - 90);
break;
case 151:
case 152:
case 153:
case 154:
case 155:
player.setAttribute("newArms", button - 90);
break;
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
player.setAttribute("newBodyColour", button - 90);
break;
case 106:
if (player.getInventory().remove(COINS)) {
if (player.getAttribute("newBody") != null) {
player.getAppearance().getTorso().changeLook((Integer) player.getAttribute("newBody"));
}
if (player.getAttribute("newArms") != null) {
player.getAppearance().getArms().changeLook((Integer) player.getAttribute("newArms"));
}
if (player.getAttribute("newBodyColour") != null) {
player.getAppearance().getTorso().changeColor((Integer) player.getAttribute("newBodyColour"));
}
player.getAppearance().sync();
player.getInterfaceManager().close();
player.getDialogueInterpreter().open(548, true, true);
}
break;
}
break;
case 201:
switch (button) {
case 201:
case 131:
case 132:
case 133:
case 134:
case 135:
player.setAttribute("newLegs", button - 61);
break;
case 136:
case 137:
player.setAttribute("newLegs", button - 60);
break;
case 105:
player.setAttribute("newLegsColour", button - 105);
break;
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
player.setAttribute("newLegsColour", button - 89);
break;
case 106:
if (player.getInventory().remove(COINS)) {
if (player.getAttribute("newLegs") != null) {
player.getAppearance().getLegs().changeLook((Integer) player.getAttribute("newLegs"));
}
if (player.getAttribute("newLegsColour") != null) {
player.getAppearance().getLegs().changeColor((Integer) player.getAttribute("newLegsColour"));
}
player.getAppearance().sync();
player.getInterfaceManager().close();
player.getDialogueInterpreter().open(548, true, true);
}
break;
}
break;
}
return true;
}
}

View file

@ -0,0 +1,119 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.game.node.entity.player.link.request.trade.TradeModule;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the interface plugin used to handle all trade related functions.
* @author 'Vexia
*/
@InitializablePlugin
public final class TradeInterfacePlugin extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.put(334, this);
ComponentDefinition.put(335, this);
ComponentDefinition.put(336, this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, final int slot, int itemId) {
final TradeModule module = TradeModule.getExtension(player);
if (module == null) {
return true;
}
switch (component.getId()) {
case 334:// second accept screen
switch (button) {
case 20:// acept
module.setAccepted(true, true);
break;
case 21:// decline
module.decline();
break;
}
break;
case 335:// main accept interface
switch (opcode) {
case 155:
switch (button) {
case 16:// accept
module.setAccepted(true, true);
break;
case 18:// decline
module.decline();
break;
case 30:// withdraw one
module.getContainer().withdraw(slot, 1);
break;
}
break;
case 196:
module.getContainer().withdraw(slot, 5);
break;
case 124:
module.getContainer().withdraw(slot, 10);
break;
case 199:
module.getContainer().withdraw(slot, module.getContainer().getAmount(module.getContainer().get(slot)));
break;
case 234:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
module.getContainer().withdraw(slot, (int) getValue());
return true;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
break;
case 9:// examine.
if (TradeModule.getExtension(button == 32 ? module.getTarget() : player) == null) {
return true;
}
player.getPacketDispatch().sendMessage(TradeModule.getExtension(button == 32 ? module.getTarget() : player).getContainer().get(slot).getDefinition().getExamine());
break;
}
break;
case 336:// overlay interface
switch (opcode) {
case 155:
module.getContainer().offer(slot, 1);
break;
case 196:
module.getContainer().offer(slot, 5);
break;
case 124:
module.getContainer().offer(slot, 10);
break;
case 199:
module.getContainer().offer(slot, player.getInventory().getAmount(player.getInventory().get(slot)));
break;
case 234:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
module.getContainer().offer(slot, (int) getValue());
return true;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
break;
case 9:
player.getPacketDispatch().sendMessage(player.getInventory().get(slot).getDefinition().getExamine());
break;
}
break;
}
return true;
}
}

View file

@ -0,0 +1,37 @@
package plugin.interaction.inter;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the world map interface.
* @author Emperor
*
*/
@InitializablePlugin
public final class WorldMapInterface extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.forId(755).setPlugin(this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
switch (button) {
case 3:
player.getInterfaceManager().openWindowsPane(new Component(player.getInterfaceManager().isResizable() ? 746 : 548));
int posHash = player.getLocation().getX() << 14 | player.getLocation().getY();
player.getPacketDispatch().sendScriptConfig(622, posHash);
player.getPacketDispatch().sendScriptConfig(674, posHash);
return true;
}
return false;
}
}

View file

@ -0,0 +1,37 @@
package plugin.interaction.item;
import org.crandor.game.content.global.BirdNest;
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 searching of a bird nest item.
* @author Vexia
*/
@InitializablePlugin
public final class BirdNestPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (BirdNest nest : BirdNest.values()) {
nest.getNest().getDefinition().getConfigurations().put("option:search", this);
}
return null;
}
@Override
public boolean handle(Player player, Node node, String option) {
final Item item = (Item) node;
BirdNest.forNest(item).search(player, item);
return true;
}
@Override
public boolean isWalk() {
return false;
}
}

View file

@ -0,0 +1,64 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
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;
/**
* Represents the plugin used to handle the "read" option of a book.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public class BookreadOption extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(292).getConfigurations().put("option:read", this);
ItemDefinition.forId(757).getConfigurations().put("option:read", this);
ItemDefinition.forId(1856).getConfigurations().put("option:read", this);
ItemDefinition.forId(9003).getConfigurations().put("option:read", this);
ItemDefinition.forId(9004).getConfigurations().put("option:read", this);
ItemDefinition.forId(11710).getConfigurations().put("option:read", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final int id = getDialId(((Item) node).getId());
player.getInterfaceManager().close();
return player.getDialogueInterpreter().open(id, node);
}
@Override
public boolean isWalk() {
return false;
}
/**
* Gets the dialogue id from the item id.
* @param item the item.
* @return the dial id.
*/
public int getDialId(int item) {
switch (item) {
case 757:
return 49610758;
case 9003:
return 49610759;
/*case 9004:
return 423943;*/
case 11710:
return 2739823;
case 292:
return 183764;
case 1856:
return 387454;
}
return -1;
}
}

View file

@ -0,0 +1,33 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
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 bracelet of clay item.
* @author Vexia
*/
@InitializablePlugin
public final class BraceletOfClayPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(11074).getConfigurations().put("option:operate", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.sendMessage("You have " + (28 - player.getSavedData().getGlobalData().getBraceletClayUses()) + " uses left.");
return true;
}
@Override
public boolean isWalk() {
return false;
}
}

View file

@ -0,0 +1,65 @@
package plugin.interaction.item;
import java.util.ArrayList;
import java.util.List;
import org.crandor.cache.def.impl.ItemDefinition;
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.ChanceItem;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.Plugin;
import org.crandor.tools.RandomFunction;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.StringUtils;
/**
* Represents the casket handling plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class CasketPlugin extends OptionHandler {
/**
* Represents the casket rewards.
*/
private static final ChanceItem[] CASKET_REWARD = new ChanceItem[] { new ChanceItem(995, 8, 3000, 30), new ChanceItem(1623, 1, 30), new ChanceItem(1621, 1, 70), new ChanceItem(1619, 1, 70), new ChanceItem(1617, 1, 97), new ChanceItem(987, 1, 97), new ChanceItem(985, 1, 97), new ChanceItem(1454, 1, 30), new ChanceItem(1452, 1, 70), new ChanceItem(1462, 1, 97) };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(405).getConfigurations().put("option:open", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final ChanceItem reward = getChanceItem(CASKET_REWARD);
player.getInventory().remove((Item) node);
player.getDialogueInterpreter().sendItemMessage(reward, "You open the casket. Inside you find " + (reward.getAmount() > 1 ? "some" : (StringUtils.isPlusN(reward.getName()) ? "an" : "a")) + " " + reward.getName().toLowerCase() + ".");
player.getInventory().add(reward.getAmount() == 1 ? reward : new Item(reward.getId(), RandomFunction.random(reward.getMinimumAmount(), reward.getMaximumAmount())));
return true;
}
/**
* Gets the chance item from the array.
* @param items the items.
* @return the chance item.
*/
private ChanceItem getChanceItem(ChanceItem[] items) {
final int chance = RandomFunction.random(100);
final List<ChanceItem> chances = new ArrayList<>();
for (ChanceItem c : items) {
if (chance > c.getChanceRate()) {
chances.add(c);
}
}
return chances.size() == 0 ? items[0] : chances.get(RandomFunction.random(chances.size()));
}
@Override
public boolean isWalk() {
return false;
}
}

View file

@ -0,0 +1,65 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.content.global.consumable.Consumable;
import org.crandor.game.content.global.consumable.ConsumableProperties;
import org.crandor.game.content.global.consumable.Consumables;
import org.crandor.game.content.global.consumable.Drink;
import org.crandor.game.content.global.consumable.Food;
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;
/**
* Represents the plugin used to consume a consumable item.
* @author 'Vexia
* @author Emperor
* @version 1.0
*/
@InitializablePlugin
public final class ConsumableOptionPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.setOptionHandler("eat", this);
ItemDefinition.setOptionHandler("drink", this);
return this;
}
/**
* The last item that was recently eaten.
* Used for Karambwan "1-ticking"
*/
int lastEaten = -1;
@Override
public boolean handle(final Player player, final Node node, final String option) {
if (player.getLocks().isLocked(option)) {
return true;
}
boolean food = option.equals("eat");
if(node.asItem().getId() != 3144 || (node.asItem().getId() == 3144 && lastEaten == 3144)){
player.getLocks().lock(option, 3);
}
if (!food) {
player.getLocks().lock("eat", 2);
}
Item item = (Item) node;
if (player.getInventory().get(item.getSlot()) != item) {
return false;
}
Consumable consumable = food ? Consumables.forFood(item) : Consumables.forDrink(item);
if (consumable == null) {
consumable = food ? new Food(item.getId(), new ConsumableProperties(1)) : new Drink(item.getId(), new ConsumableProperties(1));
}
consumable.consume(((Item) node), player);
if (food) {
player.getProperties().getCombatPulse().delayNextAttack(3);
}
lastEaten = node.asItem().getId();
return true;
}
}

View file

@ -0,0 +1,69 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
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.update.flag.context.Animation;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the diano item plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class DiangoItemPlugin extends OptionHandler {
/**
* Represents the animations.
*/
private static final Animation[] ANIMATIONS = new Animation[] { new Animation(8990), new Animation(1902), new Animation(1904) };
@Override
public boolean handle(final Player player, Node node, String option) {
switch (option) {
case "fly":
player.animate(ANIMATIONS[0]);
break;
case "spin":
player.animate(ANIMATIONS[1]);
player.getPulseManager().run(new Pulse(1) {
int count = 0;
@Override
public boolean pulse() {
if (count++ >= 9) {
player.animate(ANIMATIONS[2]);
return true;
}
return false;
}
@Override
public void stop() {
super.stop();
player.animate(ANIMATIONS[2]);
}
});
break;
}
return true;
}
@Override
public boolean isWalk() {
return false;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.setOptionHandler("fly", this);
ItemDefinition.setOptionHandler("spin", this);
return this;
}
}

View file

@ -0,0 +1,139 @@
package plugin.interaction.item;
import java.util.concurrent.TimeUnit;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.container.impl.EquipmentContainer;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.combat.BattleState;
import org.crandor.game.node.entity.combat.CombatPulse;
import org.crandor.game.node.entity.combat.InteractionType;
import org.crandor.game.node.entity.combat.equipment.SwitchAttack;
import org.crandor.game.node.entity.combat.handlers.DragonfireSwingHandler;
import org.crandor.game.node.entity.impl.Projectile;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.info.portal.Perks;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.item.ItemPlugin;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.game.world.update.flag.context.Graphics;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.PluginManager;
/**
* Handles the dragonfire shield options.
* @author Emperor
*/
@InitializablePlugin
public final class DragonfireShieldPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(11283).getConfigurations().put("option:empty", this);
ItemDefinition.forId(11283).getConfigurations().put("option:inspect", this);
ItemDefinition.forId(11283).getConfigurations().put("option:operate", this);
ItemDefinition.forId(11284).getConfigurations().put("option:inspect", this);
ItemDefinition.forId(11284).getConfigurations().put("option:operate", this);
PluginManager.definePlugin(new DFSItemPlugin());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
Item item = (Item) node;
switch (option) {
case "operate":
boolean usingAttack = !player.getAttribute("dfs_spec", false);
if (!usingAttack) {
if (!player.getSettings().isSpecialToggled()) {
player.getConfigManager().set(301, 0);
}
player.removeAttribute("dfs_spec");
player.getProperties().getCombatPulse().setTemporaryHandler(null);
return true;
}
boolean notCharged = item.getId() == 11284 || item.getCharge() < 20;
if (player.hasPerk(Perks.OVERCHARGE) && player.getSavedData().getGlobalData().getOverChargeDelay() <= System.currentTimeMillis()) {
item.setCharge(1020);
player.sendMessage("You use the power from the overcharge lords & charge your shield.");
notCharged = false;
player.getSavedData().getGlobalData().setOverChargeDelay(System.currentTimeMillis() + (GameWorld.getSettings().isDevMode() ? TimeUnit.SECONDS.toMillis(10) : TimeUnit.MINUTES.toMicros(10)));
}
if (notCharged) {
player.getPacketDispatch().sendMessage("Your shield has no charges left.");
return true;
}
if (player.getLocks().isLocked("dfs_recharge")) {
player.getPacketDispatch().sendMessage("Your dragonfire shield is recharging.");
return true;
}
player.getConfigManager().set(301, 1);
player.setAttribute("dfs_spec", true);
SwitchAttack attack = new SwitchAttack(null, Animation.create(6696), Graphics.create(1165), new Graphics(1167, 96), Projectile.create(player, null, 1166, 36, 36, 80, 70, 0, 11));
DragonfireSwingHandler handler = new DragonfireSwingHandler(false, 26, attack, true) {
@Override
public int swing(Entity entity, Entity victim, BattleState state) {
if (entity instanceof Player) {
Player player = (Player) entity;
if (!player.getSettings().isSpecialToggled()) {
player.getConfigManager().set(301, 0);
}
player.removeAttribute("dfs_spec");
Item shield = player.getEquipment().get(EquipmentContainer.SLOT_SHIELD);
if (shield == null || shield.getId() != 11283) {
return -1;
}
shield.setCharge(shield.getCharge() - 20);
if (shield.getCharge() < 1) {
player.getEquipment().replace(new Item(11284), EquipmentContainer.SLOT_SHIELD);
}
EquipmentContainer.updateBonuses(player);
player.getLocks().lock("dfs_recharge", player.hasPerk(Perks.OVERCHARGE) ? 25 : 50);
}
return super.swing(entity, victim, state);
}
};
attack.setHandler(handler);
Entity victim = player.getProperties().getCombatPulse().getVictim();
if (player.getProperties().getCombatPulse().isAttacking() && handler.canSwing(player, victim) == InteractionType.STILL_INTERACT) {
CombatPulse.swing(player, victim, handler);
return true;
}
player.getProperties().getCombatPulse().setTemporaryHandler(handler);
return true;
case "empty":
player.getInventory().replace(new Item(11284), item.getSlot());
player.graphics(Graphics.create(1160));
player.getPacketDispatch().sendMessage("You release the charges.");
return true;
case "inspect":
if (item.getId() == 11284) {
player.getPacketDispatch().sendMessage("The shield has no charges.");
return true;
}
player.getPacketDispatch().sendMessage("The shield has " + (item.getCharge() / 20) + " charges.");
return true;
}
return false;
}
public class DFSItemPlugin extends ItemPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
register(11283);
return this;
}
@Override
public Item getDeathItem(Item item) {
return new Item(11284);
}
}
}

View file

@ -0,0 +1,42 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
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;
/**
* Represents the plugin used to dust your hands.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class DustHandPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(8865).getConfigurations().put("option:dust-hands", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (option) {
case "dust-hands":
if (player.getInventory().remove((Item) node)) {
player.getPacketDispatch().sendMessage("You dust your hands with the finely ground ash.");
player.setAttribute("hand_dust", true);
}
break;
}
return true;
}
@Override
public boolean isWalk() {
return false;
}
}

View file

@ -0,0 +1,77 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.content.global.consumable.Consumable;
import org.crandor.game.content.global.consumable.Consumables;
import org.crandor.game.content.global.consumable.Drink;
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;
/**
* Represents the plugin used to handle the emptying of an item.
* @author 'Vexia
* @date 23/12/2013
*/
@InitializablePlugin
public final class EmptyOptionPlugin extends OptionHandler {
/**
* Represents the vial consumable.
*/
private static final VialConsumable VIAL_CONSUMABLE = new VialConsumable();
@Override
public boolean handle(Player player, Node node, String option) {
Consumable consumable = Consumables.forConsumable(((Item) node));
if (consumable == null) {
String name = node.getName().toLowerCase();
if (name.contains("(unf)")) {
consumable = VIAL_CONSUMABLE;
}
consumable = name.contains("potion") || name.contains("+") || name.contains("mix") || name.equals("plant cure") ? VIAL_CONSUMABLE : new Drink(((Item) node), null);
}
consumable.interact(player, node, option);
return true;
}
@Override
public boolean isWalk() {
return false;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.setOptionHandler("empty", this);
ItemDefinition.setOptionHandler("empty dish", this);
return this;
}
/**
* Represents a vial consumable.
* @author 'Vexia
* @date 23/12/2013
*/
public static class VialConsumable extends Consumable {
/**
* Constructs a new {@code VialConsumable} {@code Object}.
* @param item the item.
*/
public VialConsumable() {
super(null, null);
}
public String getEmptyMessage(Item item) {
return "You empty the vial.";
}
@Override
public Item getEmptyItem() {
return VIAL;
}
}
}

View file

@ -0,0 +1,139 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.cache.def.impl.NPCDefinition;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.global.EnchantedJewellery;
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.world.map.zone.impl.DonatorZone;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle enchanted jewellery transportation.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class EnchantedGemPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(4155).getConfigurations().put("option:check", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.sendMessage("You're assigned to kill " + NPCDefinition.forId((player.getSlayer().getTask().getNpcs()[0])).getName().toLowerCase() + "s; only " + player.getSlayer().getAmount() + " more to go.");
return true;
}
@Override
public boolean isWalk() {
return false;
}
/**
* Represents the jewellery dialogue plugin.
* @author 'Vexia
* @version 1.0
*/
public final class JewelleryDialogue extends DialoguePlugin {
/**
* Represents the id to use.
*/
public static final int ID = 329128389;
/**
* Represents the enchanted jewellery.
*/
private EnchantedJewellery jewellery;
/**
* If the operate option is used.
*/
private boolean operate;
/**
* Represents the item instance.
*/
private Item item;
/**
* Constructs a new {@code EnchantedJewelleryPlugin} {@code Object}.
*/
public JewelleryDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code EnchantedJewelleryPlugin} {@code Object}.
* @param player the player.
*/
public JewelleryDialogue(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new JewelleryDialogue(player);
}
@Override
public boolean open(Object... args) {
item = (Item) args[0];
jewellery = (EnchantedJewellery) args[1];
operate = args.length > 2 && (Boolean) args[2];
if (jewellery == EnchantedJewellery.DIGSITE_PENDANT) {
jewellery.use(player, item, 0, operate);
return true;
}
if (player.isDonator()) {
if (jewellery == EnchantedJewellery.AMULET_OF_GLORY || jewellery == EnchantedJewellery.AMULET_OF_GLORY_T) {
options("Donator Zone", "Other");
stage = -1;
return true;
}
}
interpreter.sendOptions("Where would you like to go?", jewellery.getOptions());
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
if (stage == -1) {
switch (buttonId) {
case 1:
end();
DonatorZone.getInstance().invite(player, null);
break;
case 2:
interpreter.sendOptions("Where would you like to go?", jewellery.getOptions());
break;
}
stage = 0;
return true;
}
if (player.getInterfaceManager().isOpened()) {
end();
return true;
}
end();
jewellery.use(player, item, (buttonId - 1), operate);
return true;
}
@Override
public int[] getIds() {
return new int[] { ID };
}
}
}

View file

@ -0,0 +1,152 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.global.EnchantedJewellery;
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.world.map.zone.impl.DonatorZone;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the plugin used to handle enchanted jewellery transportation.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class EnchantedJewelleryPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
new JewelleryDialogue().init();
for (EnchantedJewellery jewellery : EnchantedJewellery.values()) {
for (int id : jewellery.getIds()) {
ItemDefinition.forId(id).getConfigurations().put("option:rub", this);
ItemDefinition.forId(id).getConfigurations().put("option:operate", this);
}
}
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final EnchantedJewellery jewellery = EnchantedJewellery.forItem((Item) node);
if (jewellery.isLast(jewellery.getItemIndex((Item) node))) {
player.getPacketDispatch().sendMessage("The " + jewellery.getNameType((Item) node) + " has lost its charge.");
player.getPacketDispatch().sendMessage("It will need to be recharged before you can use it again.");
return true;
}
player.getPacketDispatch().sendMessage("You rub the " + jewellery.getNameType((Item) node) + "...");
player.getDialogueInterpreter().open(JewelleryDialogue.ID, node, jewellery, option.equals("operate"));
return true;
}
@Override
public boolean isWalk() {
return false;
}
/**
* Represents the jewellery dialogue plugin.
* @author 'Vexia
* @version 1.0
*/
public final class JewelleryDialogue extends DialoguePlugin {
/**
* Represents the id to use.
*/
public static final int ID = 329128389;
/**
* Represents the enchanted jewellery.
*/
private EnchantedJewellery jewellery;
/**
* If the operate option is used.
*/
private boolean operate;
/**
* Represents the item instance.
*/
private Item item;
/**
* Constructs a new {@code EnchantedJewelleryPlugin} {@code Object}.
*/
public JewelleryDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code EnchantedJewelleryPlugin} {@code Object}.
* @param player the player.
*/
public JewelleryDialogue(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new JewelleryDialogue(player);
}
@Override
public boolean open(Object... args) {
item = (Item) args[0];
jewellery = (EnchantedJewellery) args[1];
operate = args.length > 2 && (Boolean) args[2];
if (jewellery == EnchantedJewellery.DIGSITE_PENDANT) {
jewellery.use(player, item, 0, operate);
return true;
}
if (player.isDonator()) {
if (jewellery == EnchantedJewellery.AMULET_OF_GLORY || jewellery == EnchantedJewellery.AMULET_OF_GLORY_T) {
options("Donator Zone", "Other");
stage = -1;
return true;
}
}
interpreter.sendOptions("Where would you like to go?", jewellery.getOptions());
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
if (stage == -1) {
switch (buttonId) {
case 1:
end();
DonatorZone.getInstance().invite(player, null);
break;
case 2:
interpreter.sendOptions("Where would you like to go?", jewellery.getOptions());
break;
}
stage = 0;
return true;
}
if (player.getInterfaceManager().isOpened()) {
end();
return true;
}
end();
jewellery.use(player, item, (buttonId - 1), operate);
return true;
}
@Override
public int[] getIds() {
return new int[] { ID };
}
}
}

View file

@ -0,0 +1,96 @@
package plugin.interaction.item;
import java.util.concurrent.TimeUnit;
import org.crandor.cache.def.impl.ItemDefinition;
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.entity.player.link.TeleportManager.TeleportType;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Handles the explorers ring.
* @author Vexia
*
*/
@InitializablePlugin
public class ExplorersRingPlugin extends OptionHandler {
/**
* The cabbage port location.
*/
private static final Location CABBAGE_PORT = Location.create(3051, 3291, 0);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.setOptionHandler("run-replenish", this);
ItemDefinition.setOptionHandler("low-alchemy", this);
ItemDefinition.setOptionHandler("cabbage-port", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final Item item = (Item) node;
int level = getLevel(item.getId());
switch (option) {
case "run-replenish":
if (player.getSavedData().getGlobalData().getRunReplenishDelay() < System.currentTimeMillis()) {
player.getSavedData().getGlobalData().setRunReplenishCharges(0);
player.getSavedData().getGlobalData().setRunReplenishDelay(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1));
}
int charges = player.getSavedData().getGlobalData().getRunReplenishCharges();
if (charges >= level) {
player.sendMessage("You have used all the charges you can for one day.");
return true;
}
player.getSettings().updateRunEnergy(-50);
player.getSavedData().getGlobalData().setRunReplenishCharges(charges + 1);
player.sendMessage("You replenish 50% of your run energy.");
break;
case "low-alchemy":
if (player.getSkills().getStaticLevel(Skills.MAGIC) < 21) {
player.sendMessage("You need a Magic level of 21 in order to do that.");
break;
}
if (player.getSavedData().getGlobalData().getLowAlchemyDelay() < System.currentTimeMillis()) {
player.getSavedData().getGlobalData().setLowAlchemyCharges(0);
player.getSavedData().getGlobalData().setLowAlchemyDelay(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1));
}
if (player.getSavedData().getGlobalData().getLowAlchemyCharges() > 0 || player.getSavedData().getGlobalData().getLowAlchemyCharges() == 0 && player.getSavedData().getGlobalData().getLowAlchemyDelay() > System.currentTimeMillis()) {
player.sendMessage("You have used all the charges you can for one day.");
return true;
}
player.sendMessage("You grant yourself with 30 free low alchemy charges.");
player.getSavedData().getGlobalData().setLowAlchemyCharges(30);
break;
case "cabbage-port":
player.getTeleporter().send(CABBAGE_PORT, TeleportType.CABBAGE);
break;
}
return true;
}
/**
* Gets the level of the ring.
* @param itemId The item id.
* @return The level.
*/
private int getLevel(int itemId) {
switch (itemId) {
case 13560:
return 1;
case 13561:
return 2;
case 13562:
return 3;
}
return -1;
}
}

View file

@ -0,0 +1,43 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.content.global.LightSource;
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.world.map.zone.impl.DarkZone;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the extinguish light plugin.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class ExtinguishLightPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.setOptionHandler("extinguish", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final LightSource source = LightSource.forProductId(((Item) node).getId());
if (source == null) {
System.err.println("Extinguish Light Plugin source not found - " + ((Item) node).getId() + ".");
return true;
}
player.getInventory().replace(source.getRaw(), ((Item) node).getSlot());
DarkZone.checkDarkArea(player);
return true;
}
@Override
public boolean isWalk() {
return false;
}
}

View file

@ -0,0 +1,40 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.container.impl.EquipmentContainer;
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 gnome copter plugin.
* @author Vexia
*/
@InitializablePlugin
public final class GnomeCopterPlugin implements Plugin<Object> {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(12842).getConfigurations().put("equipment", this);
return this;
}
@Override
public Object fireEvent(String identifier, Object... args) {
final Player player = (Player) args[0];
final Item item = (Item) args[1];
switch (identifier) {
case "equip":
break;
case "unequip":
if (item.getId() == 12842) {
player.getEquipment().remove(item, EquipmentContainer.SLOT_WEAPON, true);
return false;
}
break;
}
return false;
}
}

View file

@ -0,0 +1,38 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.component.Component;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.RandomFunction;
/**
* The gnomecopter ticket handling plugin.
* @author Emperor
*/
@InitializablePlugin
public final class GnomecopterTicket extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(12843).getConfigurations().put("option:read", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.getInterfaceManager().open(new Component(729));
String info = "Gnomecopter ticket:";
info += "<br>" + "Castle Wars"; // Destination
info += "<br>" + "Ref. #000";
for (int i = 3; i < 8; i++) {
info += RandomFunction.randomize(10);
}
player.getPacketDispatch().sendString(info, 729, 2);
return true;
}
}

View file

@ -0,0 +1,328 @@
package plugin.interaction.item;
import org.crandor.game.content.dialogue.DialogueAction;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.global.GodBook;
import org.crandor.game.content.skill.Skills;
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.GroundItem;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.item.ItemPlugin;
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.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.PluginManager;
/**
* Handles the god books.
* @author Vexia
*/
@InitializablePlugin
public class GodBookPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (GodBook book : GodBook.values()) {
book.getDamagedBook().getDefinition().getConfigurations().put("option:check", this);
book.getBook().getDefinition().getConfigurations().put("option:preach", this);
}
PluginManager.definePlugin(new PageHandler(), new GodBookDialogue(), new GodBookItem(), new SymbolBlessHandler());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
GodBook book = GodBook.forItem(node.asItem(), option.equalsIgnoreCase("check"));
if (book != null) {
switch (option) {
case "check":
String[] messages = new String[4];
for (int i = 0; i < messages.length; i++) {
messages[i] = book.hasPage(player, node.asItem(), i + 1) ? "The " + getNumberName(i + 1) + " page is in the book." : "The " + getNumberName(i + 1) + " page is missing.";
}
player.getDialogueInterpreter().sendDialogue(messages);
return true;
case "preach":
player.getDialogueInterpreter().open("god-book", book);
return true;
}
}
return true;
}
/**
* Handles the blessing of a symbol with a god book.
* @author Vexia
*/
public class SymbolBlessHandler extends UseWithHandler {
/**
* Constructs a new {@code SymbolBlessHandler} {@code Object}
*/
public SymbolBlessHandler() {
super(1716);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (GodBook book : GodBook.values()) {
addHandler(book.getBook().getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
Player player = event.getPlayer();
GodBook book = GodBook.forItem(event.getUsedItem(), false);
if (book == null) {
return false;
}
final Item symbol = event.getUsedWith().asItem();
if (player.getSkills().getLevel(Skills.PRAYER) < 50) {
player.sendMessage("You need a Prayer level of at least 50 in order to do this.");
return true;
}
if (player.getSkills().getPrayerPoints() < 4) {
player.sendMessage("You need at least 4 prayer points in order to do this.");
return true;
}
if (book == GodBook.BOOK_OF_BALANCE) {
player.getDialogueInterpreter().sendOptions("Select an Option", "Unholy symbol", "Holy symbol");
player.getDialogueInterpreter().addAction(new DialogueAction() {
@Override
public void handle(Player player, int buttonId) {
bless(player, symbol, buttonId == 1 ? GodBook.UNHOLY_BOOK : GodBook.HOLY_BOOK);
}
});
return true;
}
bless(player, symbol, book);
return true;
}
/**
* Blesses a symbol.
* @param player the player.
* @param book the book.
*/
private void bless(Player player, Item symbol, GodBook book) {
if (!player.getInventory().containsItem(symbol)) {
return;
}
if (player.getInventory().get(symbol.getSlot()) == null) {
return;
}
player.getInventory().replace(book.getBlessItem()[0], symbol.getSlot());
player.getSkills().decrementPrayerPoints(4);
}
}
/**
* A god book item.
* @author Vexia
*/
public class GodBookItem extends ItemPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (GodBook book : GodBook.values()) {
register(book.getDamagedBook().getId());
}
return this;
}
@Override
public boolean canPickUp(Player player, GroundItem item, int type) {
if (player.hasItem(item.asItem())) {
player.sendMessage("You do not need more than one incomplete book.");
return false;
}
return true;
}
}
/**
* Handles the god book dialogue.
* @author Vexia
*/
public static class GodBookDialogue extends DialoguePlugin {
/**
* The partnership messages.
*/
private static final String[][] PARTNERSHIPS = new String[][] { { "In the name of Saradomin,", "protector of us all,", " I now join you in the eyes of Saradomin." }, { "Light and dark,", "day and night,", "Balance arises from constrast.", "I unify thee in the name of Guthix." }, { "May your union not be harmonious,", "but may your conflicts make you stronger,", "in Zamorak's name,", "now two are one." } };
/**
* The last rite messages.
*/
private static final String[][] LAST_RITES = new String[][] { { "Thy cause was false,", "thy skills did lack;", "See you in Lumbridge when you get back." }, { "Thy death was not in vain,", "For it brought some balance to the world.", "May guthix bring thee rest." }, { "The weak deserve to die,", "so the strong may flourish.", "This is the creed of Zamorak." } };
/**
* The blessing messages.
*/
private static final String[][] BLESSINGS = new String[][] { { "Go in peace in the name of Saradomin;", "may his glory shine upon you like the sun." }, { "Mayest thou walk the path,", "and never fall,", "For Guthix walks beside thee on thy journey.", "May Guthix bring thee peace." }, { "May you reject all safe paths,", "and embrace all challenges.", "Zamorak bring you strength." } };
/**
* The preaching messages.
*/
private static final String[][] PREACH = new String[][] { { "Protect yourself,", "protect your friends.", "Mine is the glory that never ends.", "This is Saradomin's wisdom." }, { "Thee trees,", "the earth,", "the sky,", "the waters:", "All play their part upon this land.", "May Guthix bring thee balance." }, { "Battles are not lost and won;", "They simply remove the weak from the equation.", "Zamorak give me strength!" } };
private static final Animation[] ANIMATIONS = new Animation[] { new Animation(1335), new Animation(1337), new Animation(1336) };
/**
* The god book.
*/
private GodBook book;
/**
* Constructs a new {@code GodBookDialogue} {@code Object}
*/
public GodBookDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code GodBookDialogue} {@code Object}
* @param player the player.
*/
public GodBookDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new GodBookDialogue(player);
}
@Override
public boolean open(Object... args) {
book = (GodBook) args[0];
options("Wedding Ceremony", "Last Rites", "Blessings", "Preach");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
String[][] data = null;
switch (buttonId) {
case 1:
data = PARTNERSHIPS;
break;
case 2:
data = LAST_RITES;
break;
case 3:
data = BLESSINGS;
break;
case 4:
data = PREACH;
break;
}
say(data);
end();
break;
}
return true;
}
/**
* Says the messages for the type.
* @param data the data.
*/
private void say(String[][] data) {
if (player.inCombat()) {
player.sendMessage("You can't do that while in combat.");
return;
}
final String[] messages = data[book.ordinal()];
final Animation animation = ANIMATIONS[book.ordinal()];
player.animate(animation);
player.lock();
GameWorld.submit(new Pulse(2, player) {
int index = 0;
@Override
public boolean pulse() {
player.animate(animation);
player.sendChat(messages[index]);
return index++ >= messages.length - 1;
}
@Override
public void stop() {
super.stop();
player.unlock();
}
});
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("god-book") };
}
}
/**
* The page handler.
* @author Vexia
*/
public class PageHandler extends UseWithHandler {
/**
* Constructs a new {@code PageHandler} {@code Object}
*/
public PageHandler() {
super(3839, 3841, 3843);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (GodBook book : GodBook.values()) {
for (Item i : book.getPages()) {
addHandler(i.getId(), ITEM_TYPE, this);
}
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
GodBook book = GodBook.forItem(event.getUsedItem(), true);
Player player = event.getPlayer();
if (book != null && book.isPage(event.getUsedWith().asItem())) {
book.insertPage(player, event.getUsedItem(), event.getUsedWith().asItem());
return true;
}
return false;
}
}
/**
* Gets the number name.
* @param the integer to check.
* @return the number name.
*/
private String getNumberName(int i) {
return i == 1 ? "first" : i == 2 ? "second" : i == 3 ? "third" : "fourth";
}
}

View file

@ -0,0 +1,55 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
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;
/**
* Represents the godsword dismantle plugin.
* @author Emperor
* @version 1.0
*/
@InitializablePlugin
public final class GodswordDismantlePlugin extends OptionHandler {
/**
* Represents the godsword blade item.
*/
private static final Item BLADE = new Item(11690);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(11694).getConfigurations().put("option:dismantle", this);
ItemDefinition.forId(11696).getConfigurations().put("option:dismantle", this);
ItemDefinition.forId(11698).getConfigurations().put("option:dismantle", this);
ItemDefinition.forId(11700).getConfigurations().put("option:dismantle", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
final Item item = (Item) node;
if (item.getSlot() < 0 || player.getInventory().getNew(item.getSlot()).getId() != item.getId()) {
return true;
}
final int freeSlot = player.getInventory().freeSlot();
if (freeSlot == -1) {
player.getPacketDispatch().sendMessage("Not enough space in your inventory!");
return true;
}
player.getPacketDispatch().sendMessage("You detach the hilt from the blade.");
player.getInventory().replace(null, item.getSlot(), false);
player.getInventory().add(BLADE, new Item(11702 + (item.getId() - 11694)));
return true;
}
@Override
public boolean isWalk() {
return false;
}
}

View file

@ -0,0 +1,85 @@
package plugin.interaction.item;
import java.util.ArrayList;
import java.util.List;
import org.crandor.cache.def.impl.ItemDefinition;
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.ChanceItem;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.RandomFunction;
/**
* Handles the herb box item.
* @author Vexia
*
*/
@InitializablePlugin
public class HerbBoxPlugin extends OptionHandler {
/**
* The herbs to recieve.
*/
private static final ChanceItem[] HERBS = new ChanceItem[] {new ChanceItem(199, 1, 25), new ChanceItem(201, 1, 18), new ChanceItem(203, 1, 13), new ChanceItem(205, 1, 11), new ChanceItem(207, 1, 8), new ChanceItem(209, 1, 6), new ChanceItem(211, 1, 4), new ChanceItem(213, 1, 5), new ChanceItem(215, 1, 3), new ChanceItem(2485, 1, 3), new ChanceItem(217, 1, 3)};
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(14810).getConfigurations().put("option:bank-all", this);
ItemDefinition.forId(14810).getConfigurations().put("option:take-one", this);
ItemDefinition.forId(14810).getConfigurations().put("option:check", this);
return null;
}
@Override
public boolean handle(Player player, Node node, String option) {
Item box = node.asItem();
int herbs = 10 - (1000 - box.getCharge());
if (herbs < 0 || herbs > 10) {
player.getInventory().remove(box, box.getSlot(), true);
return true;
}
player.lock(1);
switch (option) {
case "bank-all":
if (player.getBank().freeSlots() < herbs) {
player.sendMessage("You don't have enough bank space to bank all those herbs.");
break;
}
List<ChanceItem> herbList = new ArrayList<>();
for (int i = 0; i < herbs; i++) {
herbList.add(RandomFunction.getChanceItem(HERBS));
}
if (player.getInventory().remove(box, box.getSlot(), true)) {
player.getBank().add(herbList.toArray(new ChanceItem[] {}));
player.sendMessage(herbs + " herbs have been deposited into your bank.");
}
break;
case "take-one":
if (player.getInventory().freeSlots() < 1) {
player.sendMessage("You don't have enough space in your inventory.");
break;
}
ChanceItem herb = RandomFunction.getChanceItem(HERBS);
player.getInventory().add(herb.getRandomItem());
box.setCharge(box.getCharge() - 1);
if (box.getCharge() <= 990) {
player.getInventory().remove(box, box.getSlot(), true);
}
player.sendMessage("You take a herb from the box.");
break;
case "check":
player.sendMessage("The herb box contains " + herbs + " herbs.");
break;
}
return true;
}
@Override
public boolean isWalk() {
return false;
}
}

View file

@ -0,0 +1,188 @@
package plugin.interaction.item;
import java.text.DecimalFormat;
import java.util.concurrent.TimeUnit;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.content.dialogue.DialogueInterpreter;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.global.ttrail.ClueLevel;
import org.crandor.game.content.global.ttrail.ClueScrollPlugin;
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.state.EntityState;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.repository.Repository;
import org.crandor.plugin.Plugin;
import org.crandor.plugin.PluginManager;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.RandomFunction;
/**
* Handles the keldagrim voting bond item.
* @author Vexia
*
*/
@InitializablePlugin
public class KeldagrimVotingBond extends OptionHandler {
/**
* The keldagrim bond item.
*/
private static final Item BOND = new Item(14807);
/**
* The ultra lamp item.
*/
private static final Item ULTRA_LAMP = new Item(14820);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(14807).getConfigurations().put("option:redeem", this);
ItemDefinition.forId(14807).getConfigurations().put("option:deposit", this);
PluginManager.definePlugin(new keldagrimVotingBondDialogue());
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
Item item = node.asItem();
switch (option) {
case "redeem":
player.getDialogueInterpreter().open(DialogueInterpreter.getDialogueKey("keldagrim-bond"));
break;
case "deposit":
if (!player.getBank().hasSpaceFor(item)) {
player.sendMessage("You don't have enough space in your bank for that item.");
return true;
}
if (player.getInventory().remove(item)) {
player.getBank().add(item);
player.sendMessage("You deposit your Keldagrim voting bond into your bank.");
}
break;
}
return true;
}
@Override
public boolean isWalk() {
return false;
}
/**
* Handles the keldagrim voting bond dialogue.
* @author Vexia
*
*/
public class keldagrimVotingBondDialogue extends DialoguePlugin {
/**
* Constructs the {@code keldagrimVotingBondDialogue}
*/
public keldagrimVotingBondDialogue() {
/**
* empty.
*/
}
/**
* Constructs the {@code keldagrimVotingBondDialogue}
* @param player The player.
*/
public keldagrimVotingBondDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new keldagrimVotingBondDialogue(player);
}
@Override
public boolean open(Object... args) {
options("Double Experience (1 Hour)", "30K Experience Lamp", "10k-75k Coins", "Clue Scroll");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
stage = 1;
switch (buttonId) {
case 1:
if (player.getSavedData().getGlobalData().hasDoubleExp()) {
interpreter.sendItemMessage(14807, "You already have <col=FF0000>double EXP</col> active!");
return true;
}
if (player.getInventory().remove(BOND)) {
player.getSavedData().getGlobalData().setDoubleExp(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1));
player.getStateManager().set(EntityState.DOUBLE_EXPERIENCE, 6000, 0);
interpreter.sendItemMessage(14807, "You redeemed an <col=FF0000>hour</col> of double EXP!");
Repository.sendNews("" + player.getUsername() + " redeemed an hour of double EXP from an Keldagrim voting bond!", 15, "<col=FF0000>");
}
break;
case 2:
if (!player.getInventory().hasSpaceFor(ULTRA_LAMP)) {
interpreter.sendItemMessage(14807, "Sorry, you don't have enough inventory space.");
return true;
}
if (player.getInventory().remove(BOND)) {
player.getInventory().add(ULTRA_LAMP);
interpreter.sendItemMessage(14807, "You redeem an <col=FF0000>ultra lamp</col>.");
Repository.sendNews("" + player.getUsername() + " redeemed an ultra lamp from an Keldagrim voting bond!", 15, "<col=FF0000>");
return true;
}
break;
case 3:
Item coins = new Item(995, RandomFunction.random(10000, 75000));
if (!player.getInventory().hasSpaceFor(coins)) {
interpreter.sendItemMessage(14807, "Sorry, you don't have enough inventory space.");
return true;
}
if (player.getInventory().remove(BOND)) {
DecimalFormat formatter = new DecimalFormat("#,###");
player.getInventory().add(coins);
interpreter.sendItemMessage(14807, "You redeem <col=FF0000>" + formatter.format(coins.getAmount()) + "</col> gold coins.");
Repository.sendNews("" + player.getUsername() + " redeemed " + formatter.format(coins.getAmount()) + " gold coins from an Keldagrim voting bond!", 15, "<col=FF0000>");
}
break;
case 4:
if (player.getInventory().freeSlots() < 1) {
interpreter.sendItemMessage(14807, "Sorry, you don't have enough inventory space.");
return true;
}
if (player.getTreasureTrailManager().hasClue()) {
interpreter.sendItemMessage(14807, "Sorry, you already have a clue scroll.");
break;
}
if (player.getTreasureTrailManager().hasTrail()) {
player.getTreasureTrailManager().clearTrail();
}
Item clue = ClueScrollPlugin.getClue(RandomFunction.getRandomElement(ClueLevel.values()));
if (player.getInventory().remove(BOND)) {
player.getInventory().add(clue);
interpreter.sendItemMessage(14807, "You redeem a <col=FF0000>clue scroll</col>.");
Repository.sendNews("" + player.getUsername() + " redeemed a clue scroll from an Keldagrim voting bond!", 15, "<col=FF0000>");
}
break;
}
break;
case 1:
end();
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] {DialogueInterpreter.getDialogueKey("keldagrim-bond")};
}
}
}

View file

@ -0,0 +1,39 @@
package plugin.interaction.item;
import org.crandor.game.component.Component;
import org.crandor.game.content.global.Lamps;
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 an experience lamp.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class LampPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Lamps lamp : Lamps.values()) {
lamp.getItem().getDefinition().getConfigurations().put("option:rub", this);
}
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.setAttribute("lamp", node);
player.getInterfaceManager().open(new Component(134));
return true;
}
@Override
public boolean isWalk() {
return false;
}
}

View file

@ -0,0 +1,109 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.component.CloseEvent;
import org.crandor.game.component.Component;
import org.crandor.game.component.ComponentDefinition;
import org.crandor.game.component.ComponentPlugin;
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.Plugin;
import org.crandor.plugin.PluginManager;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.RandomFunction;
/**
* Handles a morph item.
* @author Vexia
*/
@InitializablePlugin
public class MorphItemPlugin implements Plugin<Object> {
/**
* The easter egg ids.
*/
protected static final int[] EASTER_EGG_IDS = new int[] { 3689, 3690, 3691, 3692, 3693, 3694 };
/**
* The morph component.
*/
private static final Component COMPONENT = new Component(375).setCloseEvent(new CloseEvent() {
@Override
public boolean close(Player player, Component c) {
unmorph(player);
return true;
}
});
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(7927).getConfigurations().put("equipment", this);
ItemDefinition.forId(6583).getConfigurations().put("equipment", this);
PluginManager.definePlugin(new MorphInterfacePlugin());
return this;
}
@Override
public Object fireEvent(String identifier, Object... args) {
final Player player = (Player) args[0];
final Item item = (Item) args[1];
switch (identifier) {
case "equip":
morph(player, item);
return false;
}
return true;
}
/**
* Morphs the player.
* @param player the player.
* @param item the item.
*/
private void morph(Player player, Item item) {
int morphId = item.getId() == 6583 ? 2626 : EASTER_EGG_IDS[RandomFunction.random(EASTER_EGG_IDS.length)];
player.getInterfaceManager().close();
player.getAppearance().transformNPC(morphId);
player.getInterfaceManager().hideTabs(0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
player.getLocks().lockMovement(GameWorld.getTicks() + 900000000);
player.getLocks().lockInteractions(GameWorld.getTicks() + 90000000);
player.getLocks().lockTeleport(GameWorld.getTicks() + 900000000);
player.getInterfaceManager().openSingleTab(COMPONENT);
player.getAppearance().sync();
player.getWalkingQueue().reset();
}
/**
* Unmorphs the player.
* @param player the player.
*/
private static void unmorph(Player player) {
player.getAppearance().transformNPC(-1);
player.unlock();
player.getInterfaceManager().restoreTabs();
}
/**
* Handles the morph interface plugin.
* @author Vexia
*/
public class MorphInterfacePlugin extends ComponentPlugin {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ComponentDefinition.forId(375).setPlugin(this);
return this;
}
@Override
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
player.getInterfaceManager().closeSingleTab();
return true;
}
}
}

View file

@ -0,0 +1,35 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.component.Component;
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 new comper map.
* @author 'Vexia
*/
@InitializablePlugin
public class NewComerMapPlugin extends OptionHandler {
@Override
public boolean handle(Player player, Node node, String option) {
player.getInterfaceManager().open(new Component(270));
return true;
}
@Override
public boolean isWalk() {
return false;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(550).getConfigurations().put("option:read", this);
return this;
}
}

View file

@ -0,0 +1,45 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.component.Component;
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 news paper.
* @author 'Vexia
*/
@InitializablePlugin
public class NewsPaperPlugin extends OptionHandler {
@Override
public boolean handle(Player player, Node node, String option) {
int id = ((Item) node).getId();
if (id == 11169) {
player.getInterfaceManager().open(new Component(530));
final String page1 = "Varrock gets Makeover! The city of Varrock is the latest recipient of a complete makeover. When interviewed, King Roald said, 'In order to keep visitors coming to see the sights of our beautiful capital, we felt that tidying-up the city would be more effective than just issuing a decree - make sure you visit the new museum while you are here.'";
final String page2 = "Obituaries Goblin-Died Giant Rat-Died Unicorn-Died Varrock Guard-Died Varrock Guard-Died Bear-Died. Classifieds.";
player.getPacketDispatch().sendString(page1, 530, 2);
player.getPacketDispatch().sendString(page2, 530, 4);
return true;
} else
player.getDialogueInterpreter().open(70099, "Come to the Al Kharid Market place! Highquality", "produce at low, low prices! Show this flyer to a", "merchant for money off your next purchase,", "courtesy of Ali Morrisane!");
return true;
}
@Override
public boolean isWalk() {
return false;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(7922).getConfigurations().put("option:read", this);
ItemDefinition.forId(11169).getConfigurations().put("option:read", this);
return this;
}
}

View file

@ -0,0 +1,41 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
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.Plugin;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.RandomFunction;
/**
* Represents an oyster plugin handler.
* @author 'Vexia
* @version 1.0
*/
@InitializablePlugin
public final class OysterPlugin extends OptionHandler {
/**
* Represents the oyster items.
*/
private static final Item[] OYSTERS = new Item[] { new Item(409), new Item(411), new Item(413) };
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(407).getConfigurations().put("option:open", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
player.getInventory().replace(RandomFunction.random(5) < 3 ? OYSTERS[RandomFunction.random(OYSTERS.length - 1)] : OYSTERS[RandomFunction.random(OYSTERS.length)], ((Item) node).getSlot());
return true;
}
@Override
public boolean isWalk() {
return false;
}
}

View file

@ -0,0 +1,42 @@
package plugin.interaction.item;
import org.crandor.cache.def.impl.ItemDefinition;
import org.crandor.game.content.global.action.PickupHandler;
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.world.map.Location;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* Represents the option handler used for ground items.
* @author Vexia
* @author Emperor
*/
@InitializablePlugin
public final class PickupPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.setOptionHandler("take", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
if (player.getAttributes().containsKey("pickup"))
return false;
player.setAttribute("pickup", "true");
boolean handleResult = PickupHandler.take(player, (GroundItem) node);
player.removeAttribute("pickup");
return handleResult;
}
@Override
public Location getDestination(Node node, Node item) {
return null;
}
}

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