Nature Spirit quest

This commit is contained in:
Ceikry
2021-08-16 02:22:10 +00:00
parent 0e2f51f851
commit b23aa7bc0d
38 changed files with 1345 additions and 298 deletions
@@ -109,6 +109,10 @@ public abstract class Consumable implements Plugin<Object> {
return effect.getHealthEffectValue(player);
}
public ConsumableEffect getEffect() {
return effect;
}
public int[] getIds() {
return ids;
}
@@ -381,6 +381,6 @@ public final class DrezelDialogue extends DialoguePlugin {
@Override
public int[] getIds() {
return new int[] { 1047 };
return new int[] { 7690 };
}
}
@@ -1,10 +1,16 @@
package core.game.content.dialogue;
import api.ContentAPI;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.quest.Quest;
import core.plugin.Initializable;
import core.game.node.item.Item;
import org.rs09.consts.NPCs;
import rs09.game.content.quest.members.naturespirit.NSDrezelDialogue;
import rs09.game.system.SystemLogger;
import static rs09.tools.DialogueConstKt.END_DIALOGUE;
/**
* Represents the dialogue plugin used for the drezel monument.
@@ -44,7 +50,7 @@ public final class DrezelMonumentDialogue extends DialoguePlugin {
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
final Quest quest = player.getQuestRepository().getQuest("Priest in Peril");
Quest quest = player.getQuestRepository().getQuest("Priest in Peril");
if (quest.getStage(player) == 17) {
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Ah, " + player.getUsername() + ". I see you finally made it down here.", "Things are worse than I feared. I'm not sure if I will", "be able to repair the damage.");
stage = 900;
@@ -64,9 +70,23 @@ public final class DrezelMonumentDialogue extends DialoguePlugin {
interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "So can I pass through that barrier now?");
stage = 400;
return true;
} else {
}
/*else {
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Greetings again adventurer, How go your travels in", "Morytania? Is it as evil as I have heard?");
stage = 420;
}*/
quest = player.getQuestRepository().getQuest("Nature Spirit");
if(quest.getStage(player) <= 5){
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Greetings again adventurer, How go your travels in", "Morytania? Is it as evil as I have heard?");
stage = 420;
} else if (quest.getStage(player) < 100){
ContentAPI.openDialogue(player, new NSDrezelDialogue(), npc);
} else {
npcl(FacialExpression.NEUTRAL, "I heard you finished your quest with Filliman! Great work!");
stage = END_DIALOGUE;
}
return true;
}
@@ -108,16 +128,37 @@ public final class DrezelMonumentDialogue extends DialoguePlugin {
end();
break;
case 420:
interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Well, I'm going to look around a bit more.");
options("Well, I'm going to look around a bit more.", "Is there anything else interesting to do around here?");
stage = 421;
break;
case 421:
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Well, that sounds like a good idea. Don't get into any", "trouble though!");
stage = 422;
switch(buttonId){
case 1:
playerl(FacialExpression.FRIENDLY, "Well, I'm going to look around a bit more.");
stage++;
break;
case 2:
playerl(FacialExpression.HALF_THINKING, "Is there anything else interesting to do around here?");
stage = 425;
break;
}
break;
case 422:
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Well, that sounds like a good idea. Don't get into any", "trouble though!");
stage = 423;
break;
case 423:
end();
break;
case 425:
npcl(FacialExpression.HALF_THINKING, "Well, not a great deal... but there is something you can do for me if you're interested. Though it is quite dangerous.");
stage++;
break;
case 426:
end();
player.getDialogueInterpreter().open(new NSDrezelDialogue(), npc);
player.getDialogueInterpreter().handle(0,0);
break;
case 120:
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "I need " + player.getGameAttributes().getAttribute("priest-in-peril:rune", 50) + " more.");
stage = 121;
@@ -239,6 +280,6 @@ public final class DrezelMonumentDialogue extends DialoguePlugin {
@Override
public int[] getIds() {
return new int[] { 1049 };
return new int[] { NPCs.DREZEL_7707 };
}
}
@@ -20,7 +20,7 @@ import core.plugin.Plugin;
import rs09.plugin.PluginManager;
import org.rs09.consts.Items;
import static rs09.tools.stringtools.StringToolsKt.colorize;
import static rs09.tools.stringtools.GlobalsKt.colorize;
/**
@@ -3,6 +3,7 @@ package core.game.interaction.item;
import java.util.ArrayList;
import java.util.List;
import api.ContentAPI;
import core.cache.def.impl.ItemDefinition;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
@@ -13,6 +14,9 @@ import core.plugin.Initializable;
import core.plugin.Plugin;
import core.tools.RandomFunction;
import core.tools.StringUtils;
import org.rs09.consts.Items;
import rs09.game.content.global.WeightBasedTable;
import rs09.game.content.global.WeightedItem;
/**
* Represents the casket handling plugin.
@@ -25,7 +29,16 @@ 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) };
private WeightBasedTable table = WeightBasedTable.create(
new WeightedItem(Items.COINS_995, 20, 640, 55, false),
new WeightedItem(Items.UNCUT_SAPPHIRE_1623, 1, 1, 32, false),
new WeightedItem(Items.UNCUT_EMERALD_1621, 1, 1, 16, false),
new WeightedItem(Items.UNCUT_RUBY_1619, 1, 1, 9, false),
new WeightedItem(Items.UNCUT_DIAMOND_1617, 1, 1, 2, false),
new WeightedItem(Items.COSMIC_TALISMAN_1454, 1, 1, 8, false),
new WeightedItem(Items.LOOP_HALF_OF_A_KEY_987, 1, 1, 1, false),
new WeightedItem(Items.TOOTH_HALF_OF_A_KEY_985, 1, 1, 1, false)
);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
@@ -35,10 +48,10 @@ public final class CasketPlugin extends OptionHandler {
@Override
public boolean handle(Player player, Node node, String option) {
final ChanceItem reward = getChanceItem(CASKET_REWARD);
final Item reward = table.roll().get(0);
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())));
ContentAPI.addItemOrDrop(player, reward.getId(), reward.getAmount());
return true;
}
@@ -12,6 +12,7 @@ import core.game.world.map.RegionManager;
import core.plugin.Initializable;
import core.plugin.Plugin;
import core.tools.RandomFunction;
import rs09.game.content.quest.members.naturespirit.NSUtils;
/**
* Handles the Silver Sickle (b) to collect Mort Myre Fungus.
@@ -29,45 +30,14 @@ public final class SilverSicklePlugin extends OptionHandler {
@Override
public boolean handle(Player player, Node node, String option) {
Region region = RegionManager.forId(player.getLocation().getRegionId());
switch (option) {
case "operate":
case "cast bloom":
if (player.getSkills().getPrayerPoints() < 1) {
player.getPacketDispatch().sendMessage("You don't have enough prayer points to do this.");
}
for (Scenery[] o : region.getPlanes()[0].getObjects()) {
for (Scenery obj : o) {
if (obj != null) {
if (obj.getName().equalsIgnoreCase("Rotting log") && player.getSkills().getPrayerPoints() >= 1) {
if (player.getLocation().withinDistance(obj.getLocation(), 2)) {
handleVisuals(player, node);
SceneryBuilder.add(new Scenery(3509, obj.getLocation(), obj.getRotation()));
}
}
}
}
}
RegionManager.getLock().unlock();
player.getPacketDispatch().sendAnimation(9021);
NSUtils.castBloom(player);
return true;
}
return false;
}
/**
* Handles the draining of prayer points and physical graphics and
* animation.
*/
public void handleVisuals(Player player, Node node) {
player.getSkills().decrementPrayerPoints(RandomFunction.random(1, 3));
player.getPacketDispatch().sendAnimation(9021);
final Location[] AROUND_YOU = new Location[] { Location.create(player.getLocation().getX() - 1, player.getLocation().getY(), 0), Location.create(player.getLocation().getX() + 1, player.getLocation().getY(), 0), Location.create(player.getLocation().getX(), player.getLocation().getY() - 1, 0), Location.create(player.getLocation().getX(), player.getLocation().getY() + 1, 0), Location.create(player.getLocation().getX() + 1, player.getLocation().getY() + 1, 0), Location.create(player.getLocation().getX() - 1, player.getLocation().getY() + 1, 0), Location.create(player.getLocation().getX() + 1, player.getLocation().getY() - 1, 0), Location.create(player.getLocation().getX() - 1, player.getLocation().getY() - 1, 0), Location.create(player.getLocation().getX() + 1, player.getLocation().getY() + 1, 0), };
for (Location location : AROUND_YOU) {
// The graphic is meant to play on a 3x3 radius around you, but not
// including the tile you are on.
player.getPacketDispatch().sendGlobalPositionGraphic(263, location);
}
}
}
@@ -14,6 +14,7 @@ import core.game.node.object.Scenery;
import core.game.world.map.Location;
import core.plugin.Initializable;
import core.plugin.Plugin;
import org.rs09.consts.NPCs;
/**
* Represents the quest node plugin handler.
@@ -200,7 +201,7 @@ public class PriestInPerilOptionPlugin extends OptionHandler {
}
break;
case "talk-through":
player.getDialogueInterpreter().open(1047, NPC.create(1047, player.getLocation()));
player.getDialogueInterpreter().open(NPCs.DREZEL_7690, NPC.create(NPCs.DREZEL_7690, player.getLocation()));
break;
}
break;
@@ -638,7 +638,6 @@ public abstract class Entity extends Node {
public Properties getProperties() {
return properties;
}
/**
* Gets the updateMasks.
* @return The updateMasks.
@@ -55,8 +55,9 @@ public final class DeathTask extends NodeTask {
}
}
}
e.getAnimator().forceAnimation(e.getProperties().getDeathAnimation());
e.graphics(Animator.RESET_G);
e.visualize(e.getProperties().getDeathAnimation(), e.getProperties().deathGfx);
e.getAnimator().forceAnimation(e.getProperties().getDeathAnimation());
e.commenceDeath(killer);
e.getImpactHandler().setDisabledTicks(50);
}
@@ -12,6 +12,7 @@ import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.game.world.map.Location;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import rs09.game.node.entity.combat.CombatPulse;
import rs09.game.system.config.ItemConfigParser;
import rs09.game.system.config.NPCConfigParser;
@@ -92,6 +93,8 @@ public final class Properties {
*/
private Animation deathAnimation = new Animation(9055, Animator.Priority.HIGH);
public Graphics deathGfx = new Graphics(-1);
/**
* The range animation.
*/
@@ -25,6 +25,7 @@ import core.game.world.map.RegionManager;
import core.game.world.map.build.DynamicRegion;
import core.game.world.map.path.Pathfinder;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.game.world.update.flag.npc.NPCFaceEntity;
import core.game.world.update.flag.npc.NPCFaceLocation;
import core.game.world.update.flag.npc.NPCForceChat;
@@ -305,6 +306,9 @@ public class NPC extends Entity {
if (definition.getConfiguration("movement_radius") != null) {
this.setWalkRadius(definition.getConfiguration("movement_radius"));
}
if(definition.getConfiguration("death_gfx") != null) {
getProperties().deathGfx = new Graphics(definition.getConfiguration("death_gfx"));
}
}
/**
@@ -80,7 +80,6 @@ import rs09.game.ge.PlayerGrandExchange;
import rs09.game.node.entity.combat.CombatSwingHandler;
import rs09.game.node.entity.combat.equipment.EquipmentDegrader;
import rs09.game.node.entity.skill.runecrafting.PouchManager;
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks;
import rs09.game.node.entity.state.newsys.State;
import rs09.game.node.entity.state.newsys.StateRepository;
import rs09.game.world.GameWorld;
@@ -95,7 +94,7 @@ import java.util.*;
import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_BASE;
import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_DEATHS;
import static rs09.tools.stringtools.StringToolsKt.colorize;
import static rs09.tools.stringtools.GlobalsKt.colorize;
/**
* Represents a player entity.
@@ -322,7 +322,7 @@ public final class PacketDispatch {
* @param location the location.
*/
public void sendPositionedGraphic(int id, int height, int delay, Location location) {
PacketRepository.send(PositionedGraphic.class, new PositionedGraphicContext(player, new Graphics(id, height, delay), location));
PacketRepository.send(PositionedGraphic.class, new PositionedGraphicContext(player, new Graphics(id, height, delay), location, 0, 0));
}
/**
@@ -342,8 +342,7 @@ public final class PacketDispatch {
* @param location the location.
*/
public void sendPositionedGraphics(Graphics graphics, Location location) {
PacketRepository.send(PositionedGraphic.class, new PositionedGraphicContext(player, graphics, location));
PacketRepository.send(PositionedGraphic.class, new PositionedGraphicContext(player, graphics, location, 0, 0));
}
/**
@@ -11,7 +11,7 @@ import core.net.packet.PacketRepository;
import core.net.packet.context.ContainerContext;
import core.net.packet.out.ContainerPacket;
import static rs09.tools.stringtools.StringToolsKt.colorize;
import static rs09.tools.stringtools.GlobalsKt.colorize;
/**
* Represents the container during a trade session.
@@ -87,9 +87,12 @@ public class BoneOfferPlugin extends UseWithHandler {
return;
}
final Location start = player.getLocation();
Location gfxLoc = player.getLocation().transform(player.getDirection(), 1);
ContentAPI.submitIndividualPulse(player, new Pulse(1) {
int counter = 0;
@Override
public boolean pulse() {
counter++;
@@ -97,7 +100,7 @@ public class BoneOfferPlugin extends UseWithHandler {
if (player.getInventory().remove(new Item(b.getItemId()))) {
player.animate(ANIM);
player.getAudioManager().send(new Audio(958));
player.getPacketDispatch().sendPositionedGraphics(GFX, altar.getLocation());
player.getPacketDispatch().sendPositionedGraphics(GFX, gfxLoc);
player.sendMessage(getMessage(isLit(left), isLit(right)));
player.getSkills().addExperience(Skills.PRAYER, b.getExperience() * getMod(altar, isLit(left), isLit(right)));
}
@@ -1,6 +1,7 @@
package core.game.node.entity.skill.herblore;
import core.game.node.item.Item;
import org.rs09.consts.Items;
/**
* Represents a finished potion.
@@ -21,7 +22,7 @@ public enum FinishedPotion {
SUPER_ANTIPOISON(UnfinishedPotion.IRIT, new Item(235), 48, 106.3, new Item(181)),
FISHING_POTION(UnfinishedPotion.AVANTOE, new Item(231), 50, 112.5, new Item(151)),
SUPER_ENERGY(UnfinishedPotion.AVANTOE, new Item(2970), 52, 117.5, new Item(3018)),
HUNTING_POTION(UnfinishedPotion.AVANTOE, new Item(10109), 53, 120, new Item(10000)),
HUNTING_POTION(UnfinishedPotion.AVANTOE, new Item(Items.KEBBIT_TEETH_DUST_10111), 53, 120, new Item(10000)),
SUPER_STRENGTH(UnfinishedPotion.KWUARM, new Item(225), 55, 125, new Item(157)),
WEAPON_POISON(UnfinishedPotion.KWUARM, new Item(241), 60, 137.5, new Item(187)),
SUPER_RESTORE(UnfinishedPotion.SNAPDRAGON, new Item(223), 63, 142.5, new Item(3026)),
@@ -6,6 +6,8 @@ import core.game.world.map.path.Path;
import core.game.world.map.path.Pathfinder;
import core.tools.RandomFunction;
import java.util.ArrayList;
/**
* Represents a location on the world map.
* @author Emperor
@@ -250,6 +252,24 @@ public final class Location extends Node {
return Math.sqrt(xdiff * xdiff + ydiff * ydiff);
}
/**
* Gets the 8 tiles surrounding this location as an ArrayList<Location>
*/
public ArrayList<Location> getSurroundingTiles() {
ArrayList<Location> locs = new ArrayList<>();
locs.add(transform(0,1,0)); //N
locs.add(transform(1,1,0)); //NE
locs.add(transform(1,0,0)); //E
locs.add(transform(1,-1,0)); //SE
locs.add(transform(0,-1,0)); //S
locs.add(transform(-1,-1,0));//SW
locs.add(transform(-1,0,0));//W
locs.add(transform(-1,1,0));//NW
return locs;
}
/**
* Gets the x position on the region chunk.
* @return The x position on the region chunk.
@@ -339,7 +359,7 @@ public final class Location extends Node {
* @return The local y-coordinate.
*/
public int getSceneY(Location loc) {
return y - ((loc.getRegionY() - 6) * 8);
return y - ((loc.getRegionY() - 6) << 3);
}
/**
@@ -26,16 +26,23 @@ public final class PositionedGraphicContext implements Context {
*/
private final Location location;
public int sceneX, sceneY;
public int offsetX, offsetY;
/**
* Constructs a new {@code PositionedGraphicContext} {@code Object}.
* @param player The player.
* @param graphic The graphic to display on the given location.
* @param location The location to display the graphic on.
*/
public PositionedGraphicContext(Player player, Graphics graphic, Location location) {
public PositionedGraphicContext(Player player, Graphics graphic, Location location, int offsetX, int offsetY) {
this.player = player;
this.graphic = graphic;
this.location = location;
this.sceneX = location.getSceneX(player.getPlayerFlags().getLastSceneGraph());
this.sceneY = location.getSceneY(player.getPlayerFlags().getLastSceneGraph());
this.offsetX = offsetX;
this.offsetY = offsetY;
}
@Override
@@ -338,7 +338,7 @@ public final class InteractionPacket implements IncomingPacket {
player.debug("Handled by quest interaction manager.");
return;
}
if(InteractionListeners.run(item.getId(), InteractionListener.Companion.getITEM(),option.getName(),player,item)){
if(InteractionListeners.run(item.getId(), InteractionListener.Companion.getGROUNDITEM(), option.getName(),player,item)){
return;
}
item.getInteraction().handle(player, option);
@@ -5,6 +5,7 @@ import core.game.world.update.flag.context.Graphics;
import core.net.packet.IoBuffer;
import core.net.packet.OutgoingPacket;
import core.net.packet.context.PositionedGraphicContext;
import rs09.game.system.SystemLogger;
/**
* The positioned graphic outgoing packet.
@@ -16,8 +17,16 @@ public final class PositionedGraphic implements OutgoingPacket<PositionedGraphic
public void send(PositionedGraphicContext context) {
Location l = context.getLocation();
Graphics g = context.getGraphic();
IoBuffer buffer = UpdateAreaPosition.getBuffer(context.getPlayer(), l).put(17).put((l.getChunkOffsetX() << 4) | (l.getChunkOffsetY() & 0x7)).putShort(g.getId()).put(g.getHeight()).putShort(g.getDelay());
buffer.cypherOpcode(context.getPlayer().getSession().getIsaacPair().getOutput());context.getPlayer().getSession().write(buffer);
int offsetHash = (context.offsetX << 4) | context.offsetY;
IoBuffer buffer = new IoBuffer()
.put(26) //update current scene x and scene y client-side
.putC(context.sceneX) //this has to be done for each graphic being sent
.put(context.sceneY) //opcode 26 is the lastSceneX/lastSceneY update packet
.put(17).put(offsetHash) //send the graphics
.putShort(g.getId())
.put(g.getHeight())
.putShort(g.getDelay());
context.getPlayer().getSession().write(buffer);
}
}
}