Merge pull request #113 from Jamix77/master

Fixed teleport to house and added the ability to chisel limestone into limestone bricks for construction.
This commit is contained in:
Jamix77 2020-02-25 17:43:46 +00:00 committed by GitHub
commit 06089b9a5a
4 changed files with 166 additions and 2 deletions

View file

@ -0,0 +1,70 @@
package org.crandor.game.content.skill.free.crafting.limestone;
import org.crandor.game.content.skill.SkillPulse;
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.game.world.update.flag.context.Animation;
/**
*
* The skill pulse for chiseling a limestone into a limestone brick.
*
* @author Jamix77
*
*/
public class ChiselLimestonePulse extends SkillPulse<Item> {
/**
* Represents the chisel item.
*/
private static final Item CHISEL = new Item(1755);
/**
* Represents the ticks passed.
*/
private int ticks;
public ChiselLimestonePulse(Player player, Item node) {
super(player, node);
this.resetAnimation= false;
}
@Override
public boolean checkRequirements() {
if (!player.getInventory().containsItem(CHISEL)) {
return false;
}
if (!player.getInventory().containsItem(new Item(3211))) {
return false;
}
if (player.getSkills().getLevel(Skills.CRAFTING) < 12) {
player.getPacketDispatch().sendMessage("You need a crafting level of 12 to make limestone bricks.");
return false;
}
return true;
}
@Override
public void animate() {
if (ticks % 5 == 0 || ticks < 1) {
player.getAudioManager().send(2586);
player.animate(Animation.create(4470));
}
}
@Override
public boolean reward() {
if (++ticks % 2 != 0) {
return false;
}
if (player.getInventory().remove(new Item(3211))) {
player.getInventory().add(new Item(3420));
player.getSkills().addExperience(Skills.CRAFTING, 6, true);
}
return !player.getInventory().containsItem(new Item(3211));
}
}

View file

@ -0,0 +1,38 @@
package plugin.skill.crafting;
import org.crandor.game.content.skill.free.crafting.limestone.ChiselLimestonePulse;
import org.crandor.game.interaction.NodeUsageEvent;
import org.crandor.game.interaction.UseWithHandler;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.item.Item;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.plugin.Plugin;
/**
* The plugin that starts the chisel limestone cutting pulse.
* @author Jamix77
*/
@InitializablePlugin
public final class ChiselLimestonePlugin extends UseWithHandler {
/**
* Constructs a new {@code GemCutPlugin} {@Code Object}
*/
public ChiselLimestonePlugin() {
super(3211);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(1755, ITEM_TYPE, this);
return null;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
player.getPulseManager().run(new ChiselLimestonePulse(player, new Item(3211)));
return true;
}
}

View file

@ -0,0 +1,56 @@
package plugin.skill.magic;
import org.crandor.game.content.skill.free.magic.MagicSpell;
import org.crandor.game.content.skill.free.magic.Runes;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.combat.equipment.SpellType;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.SpellBookManager.SpellBook;
import org.crandor.game.node.entity.player.link.TeleportManager.TeleportType;
import org.crandor.game.node.item.Item;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import org.crandor.plugin.Plugin;
import org.crandor.tools.RandomFunction;
/**
*
* For house teleportation.
*
* @author Jamix77
*
*/
public class HouseTeleportPlugin extends MagicSpell {
public HouseTeleportPlugin(final int level, final double experience, final Item... items) {
super(SpellBook.MODERN, level, experience, null, null, null, items);
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
System.out.println("Casting house tele");
if (((Player)entity).getHouseManager().getLocation().getExitLocation() == null) {
((Player)entity).sendMessage("You must have a house to teleport to before attempting that.");
return false;
}
Location location = ((Player)entity).getHouseManager().getLocation().getExitLocation();
if (entity.getLocks().isTeleportLocked() || !super.meetsRequirements(entity, true, false)) {
return false;
}
if (entity.getTeleporter().send(location.transform(0, RandomFunction.random(3), 0), TeleportType.NORMAL)) {
entity.setAttribute("teleport:items", super.runes);
entity.setAttribute("magic-delay", GameWorld.getTicks() + 5);
return true;
}
return false;
}
}

View file

@ -87,10 +87,10 @@ public final class ModernTeleportPlugin extends MagicSpell {
SpellBook.MODERN.register(18, new ModernTeleportPlugin(31, 41, Location.create(3221, 3219, 0), new Item(Runes.EARTH_RUNE.getId()), new Item(Runes.AIR_RUNE.getId(), 3), new Item(Runes.LAW_RUNE.getId(), 1)));
// fally
SpellBook.MODERN.register(21, new ModernTeleportPlugin(37, 47, Location.create(2965, 3378, 0), new Item(Runes.WATER_RUNE.getId()), new Item(Runes.AIR_RUNE.getId(), 3), new Item(Runes.LAW_RUNE.getId(), 1)));
// house
SpellBook.MODERN.register(23, new ModernTeleportPlugin(40, 50, ServerConstants.HOME_LOCATION, new Item(Runes.LAW_RUNE.getId()), new Item(Runes.AIR_RUNE.getId(), 1), new Item(Runes.EARTH_RUNE.getId(), 1)));
// camelot
SpellBook.MODERN.register(26, new ModernTeleportPlugin(45, 55.5, Location.create(2758, 3478, 0), new Item(Runes.AIR_RUNE.getId(), 5), new Item(Runes.LAW_RUNE.getId(), 1)));
// house
SpellBook.MODERN.register(23, new HouseTeleportPlugin(40, 50, new Item(Runes.LAW_RUNE.getId()), new Item(Runes.AIR_RUNE.getId(), 1), new Item(Runes.EARTH_RUNE.getId(), 1)));
// ardougne
SpellBook.MODERN.register(32, new ModernTeleportPlugin(51, 61, Location.create(2662, 3307, 0), new Item(Runes.WATER_RUNE.getId(), 2), new Item(Runes.LAW_RUNE.getId(), 2)));
// watchtower