Fixed teleport to house.

As Sia mentioned, all now fixed with a new teleport class.
This commit is contained in:
Jamix77 2020-02-25 10:09:36 +00:00
parent 3a370a0292
commit 36ca5ccb9a
2 changed files with 58 additions and 2 deletions

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