magic carpet + save template fix

This commit is contained in:
Ceikry 2021-03-10 20:59:50 -06:00
parent 4f7b9bac57
commit 6401d30b79
4 changed files with 30 additions and 7 deletions

View file

@ -1,6 +1,7 @@
package core.game.content.dialogue;
import core.cache.def.impl.NPCDefinition;
import core.game.container.impl.EquipmentContainer;
import core.plugin.Initializable;
import core.game.node.entity.skill.agility.AgilityHandler;
import core.game.interaction.OptionHandler;
@ -14,6 +15,9 @@ import core.game.world.map.Location;
import core.game.world.update.flag.context.Animation;
import core.plugin.Plugin;
import core.plugin.PluginManager;
import core.tools.Items;
import static core.tools.stringtools.StringToolsKt.colorize;
/**
* The dialogue plugin used for the rug merchant.
@ -147,9 +151,13 @@ public final class RugMerchantDialogue extends DialoguePlugin {
return;
}
destination = options.length == 1 ? options[0] : options[buttonId - 1];
if(player.getEquipment().get(EquipmentContainer.SLOT_WEAPON) != null){
player.sendMessage(colorize("%RYou must unequip all your weapons before you can fly on a carpet."));
} else {
if (player.getInventory().remove(new Item(995, 200))) {
destination.travel(current, player);
}
}
end();
break;
case 20:
@ -272,6 +280,9 @@ public final class RugMerchantDialogue extends DialoguePlugin {
player.lock();
player.getConfigManager().set(499, 0);
player.getImpactHandler().setDisabledTicks(GameWorld.getTicks() + 200);
player.getInterfaceManager().hideTabs(0,1,2,3,4,5,6,7,8,9,10,11,12,13);
player.getEquipment().replace(new Item(Items.MAGIC_CARPET_5614),EquipmentContainer.SLOT_WEAPON);
player.getPacketDispatch().sendInterfaceConfig(548,69,true);
GameWorld.getPulser().submit(new Pulse(1, player) {
int count;
int index;
@ -300,11 +311,13 @@ public final class RugMerchantDialogue extends DialoguePlugin {
break;
case 4:
player.getConfigManager().set(499, 1);
player.animate(FLOATING_ANIMATION);
break;
case 200:
break;
case 901:
player.getEquipment().replace(null,EquipmentContainer.SLOT_WEAPON);
player.getInterfaceManager().restoreTabs();
player.getPacketDispatch().sendInterfaceConfig(548,69,false);
player.getImpactHandler().setDisabledTicks(0);
player.unlock();
player.animate(new Animation(-1));
@ -319,7 +332,7 @@ public final class RugMerchantDialogue extends DialoguePlugin {
break;
}
if (index == 0 || player.getLocation().equals(locs[index - 1])) {
AgilityHandler.forceWalk(player, -1, player.getLocation(), locs[index++], FLOATING_ANIMATION, 40, 0.0, null);
AgilityHandler.walk(player,-1,player.getLocation(),locs[index++],null,0.0,null,true);
}
return false;
}

View file

@ -30,6 +30,9 @@ public final class PlayerParser {
if (JSON.exists()) { //parse the new JSON type.
new PlayerSaveParser(player).parse();
} else { //Create new save
if(!(new File(ServerConstants.PLAYER_SAVE_PATH + "template/template.json")).exists()){
return true;
}
makeFromTemplate(player);
new PlayerSaveParser(player).parse();
}

View file

@ -225,6 +225,10 @@ public final class AgilityHandler {
});
}
public static void walk(final Player player, final int courseIndex, final Location start, final Location end, final Animation animation, final double experience, final String message){
walk(player,courseIndex,start,end,animation,experience,message,false);
}
/**
* Uses the walking queue to walk across an obstacle.
* @param player The player.
@ -236,19 +240,19 @@ public final class AgilityHandler {
* @param experience The agility experience.
* @param message The message to send upon completion.
*/
public static void walk(final Player player, final int courseIndex, final Location start, final Location end, final Animation animation, final double experience, final String message) {
public static void walk(final Player player, final int courseIndex, final Location start, final Location end, final Animation animation, final double experience, final String message, final boolean infiniteRun) {
if (!player.getLocation().equals(start)) {
player.getPulseManager().run(new MovementPulse(player, start) {
@Override
public boolean pulse() {
walk(player, courseIndex, start, end, animation, experience, message);
walk(player, courseIndex, start, end, animation, experience, message, infiniteRun);
return true;
}
}, "movement");
return;
}
player.getWalkingQueue().reset();
player.getWalkingQueue().addPath(end.getX(), end.getY(), true);
player.getWalkingQueue().addPath(end.getX(), end.getY(), !infiniteRun);
int ticks = player.getWalkingQueue().getQueue().size();
player.getImpactHandler().setDisabledTicks(ticks);
player.lock(1 + ticks);
@ -259,6 +263,7 @@ public final class AgilityHandler {
if (animation != null) {
player.getAppearance().setAnimations(animation);
}
player.getSettings().setRunEnergy(100.0);
GameWorld.getPulser().submit(new Pulse(ticks, player) {
@Override
public boolean pulse() {

View file

@ -5,6 +5,7 @@ import core.cache.def.impl.ItemDefinition
import core.cache.def.impl.ObjectDefinition
import core.cache.def.impl.VarbitDefinition
import core.game.component.Component
import core.game.container.impl.EquipmentContainer
import core.game.node.`object`.GameObject
import core.game.node.entity.player.info.Rights
import core.game.node.entity.player.link.RunScript
@ -26,6 +27,7 @@ import core.game.ge.OfferState
import core.game.node.entity.skill.Skills
import core.game.node.entity.state.newsys.states.FarmingState
import core.tools.Components
import core.tools.Items
import core.tools.stringtools.colorize
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection