Random event shit

This commit is contained in:
Ceikry 2021-03-18 00:11:06 -05:00
parent 2952dde050
commit d3c71221c9
49 changed files with 62 additions and 3976 deletions

View file

@ -65,10 +65,6 @@ public final class AlchemySpell extends MagicSpell {
Item item = (Item) target;
Player p = (Player) entity;
p.getInterfaceManager().setViewedTab(6);
if (p.getAntiMacroHandler().hasEvent()) {
p.getPacketDispatch().sendMessage("You can't do that right now.");
return false;
}
if (item == null || p.getInventory().get(item.getSlot()) != item) {
p.sendMessage("Error! Report to admin.");
return false;

View file

@ -1,112 +0,0 @@
package core.game.content.ame;
import core.game.content.dialogue.DialoguePlugin;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.PluginManifest;
import core.plugin.PluginType;
/**
* Handles the dialogue of an anti macro npc.
* @author Vexia
*/
@PluginManifest(type = PluginType.DIALOGUE)
public abstract class AntiMacroDialogue extends DialoguePlugin {
/**
* The anti macro event.
*/
protected AntiMacroEvent event;
/**
* Constructs a new {@code AntiMacroDialogue} {@code Object}.
*/
public AntiMacroDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code AntiMacroDialogue} {@code Object}.
* @param player the player.
*/
public AntiMacroDialogue(final Player player) {
super(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
if (!player.getAntiMacroHandler().isNPC(npc, true)) {
end();
return false;
}
if (player.getAntiMacroHandler().getEvent() == null) {
return false;
}
if (asAme().inCombat()) {
asAme().getProperties().getCombatPulse().stop();
}
return true;
}
/**
* Wrapper method for waving the npc good bye.
*/
public void wave() {
wave(Animation.create(863));
}
/**
* Waves the npc good bye.
* @param wave the wave animation.
*/
public void wave(Animation wave) {
end();
npc.lock();
if (wave != null) {
npc.animate(wave);
}
GameWorld.getPulser().submit(new Pulse(4, npc, player) {
@Override
public boolean pulse() {
((AntiMacroNPC) npc).clear();
Graphics.send(new Graphics(86), npc.getLocation());
//player.getPacketDispatch().sendPositionedGraphic(86, 0, 1, npc.getLocation());
return true;
}
});
event.terminate();
}
/**
* Gets the npc as an AME.
* @return the ame.
*/
public AntiMacroNPC asAme() {
return ((AntiMacroNPC) npc);
}
/**
* Gets the event.
* @return The event.
*/
public AntiMacroEvent getEvent() {
return event;
}
/**
* Sets the event.
* @param event The event to set.
*/
public void setEvent(AntiMacroEvent event) {
this.event = event;
}
}

View file

@ -1,193 +0,0 @@
package core.game.content.ame;
import core.game.content.activity.ActivityPlugin;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.game.world.map.Location;
import core.game.world.map.zone.ZoneRestriction;
import core.tools.RandomFunction;
/**
* Handles an anti-macro event.
* @author Emperor
*/
public abstract class AntiMacroEvent extends ActivityPlugin {
/**
* The random locations to teleport to if unresponsive.
*/
public static final Location[] LOCATIONS = new Location[] { Location.create(3218, 9616, 0),// Lumby
// basement
Location.create(3200, 3228, 0),// behind lumby
Location.create(2961, 3381, 0),// Fally square
};
/**
* The skill ids.
*/
private final int[] skillIds;
/**
* The player.
*/
protected Player player;
/**
* If the anti-macro event is terminated.
*/
protected boolean terminated;
/**
* If saving is required.
*/
private boolean saveRequired;
/**
* Constructs a new {@code AntiMacroEvent} {@code Object}.
* @param name The random event name.
* @param instanced If the event is instanced.
* @param saveRequired .
* @param skillIds The skill ids of the skills that fire this event (nothing
* for default).
*/
public AntiMacroEvent(String name, boolean instanced, boolean saveRequired, int... skillIds) {
super(name, instanced, false, false, ZoneRestriction.RANDOM_EVENTS, ZoneRestriction.FIRES, ZoneRestriction.FOLLOWERS);
this.saveRequired = saveRequired;
this.skillIds = skillIds;
}
@Override
public AntiMacroEvent newInstance(Player player) {
AntiMacroHandler.register(this);
return this;
}
@Override
public abstract boolean start(Player player, boolean login, Object... args);
/**
* Creates a new anti macro event instance.
* @param player The player.
* @return The anti macro event instance.
*/
public abstract AntiMacroEvent create(Player player);
/**
* Called to end the macro event.
*/
public void terminate() {
if (terminated) {
return;
}
if (player != null) {
player.getAntiMacroHandler().setEvent(null);
}
terminated = true;
}
/**
* Initializes the random event for the player.
* @param player The player.
*/
public void init(Player player) {
player.addExtension(AntiMacroEvent.class, this);
}
/**
* Notes all the items in an inventory.
*/
public void noteItems() {
if (player == null) {
return;
}
for (Item i : player.getInventory().toArray()) {
if (i == null || !i.isActive()) {
continue;
}
if (i.getDefinition().isUnnoted()) {
int noteId = i.getDefinition().getNoteId();
if (noteId < 0) {
continue;
}
player.getInventory().remove(i);
player.getInventory().add(new Item(noteId, i.getAmount()));
}
}
player.getInventory().shift();
}
/**
* Checks if the macro event can be fired for the given skill id.
* @param skillId The skill id.
* @return {@code True} if so.
*/
public boolean canFire(int skillId) {
if (skillIds.length == 0) {
return true;
}
for (int id : skillIds) {
if (id == skillId) {
return true;
}
}
return false;
}
/**
* Gets a random location.
* @return a random location.
*/
public static Location getRandomLocation() {
return LOCATIONS[RandomFunction.random(LOCATIONS.length)];
}
/**
* Wrapper to get the gender prefix.
* @return the prefix.
*/
public String getGenderPrefix() {
return getGenderPrefix(player.getAppearance().isMale());
}
/**
* Gets the gender prefix.
* @param male if male.
* @return the prefix.
*/
public String getGenderPrefix(boolean male) {
return male ? "Sir" : "Mam";
}
/**
* Gets the terminated.
* @return The terminated.
*/
public boolean isTerminated() {
return terminated;
}
/**
* Sets the terminated.
* @param terminated The terminated to set.
*/
public void setTerminated(boolean terminated) {
this.terminated = terminated;
}
/**
* Gets the saveRequired.
* @return The saveRequired.
*/
public boolean isSaveRequired() {
return saveRequired;
}
/**
* Sets the saveRequired.
* @param saveRequired The saveRequired to set.
*/
public void setSaveRequired(boolean saveRequired) {
this.saveRequired = saveRequired;
}
}

View file

@ -1,252 +0,0 @@
package core.game.content.ame;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.entity.skill.Skills;
import core.game.world.map.zone.ZoneRestriction;
import core.game.world.map.zone.impl.WildernessZone;
import core.tools.RandomFunction;
import rs09.game.content.ame.RandomEventNPC;
import rs09.game.system.SystemLogger;
import rs09.game.world.GameWorld;
import java.util.HashMap;
import java.util.Map;
/**
* Handles anti-macroing.
* @author Emperor
* @author ceik
*/
public final class AntiMacroHandler {
/**
* The delay between periods in which it attempts to spawn a random event.
* For example, if delay is 500, it will wait 500 ticks before it starts trying to spawn a random event.
*/
private static final int DELAY = 3000; // 2000 ticks = 20 minutes
/**
* The chance that, after the delay has passed, a random event has of occuring each tick. Takes the form of (1 / CHANCE)
*/
private static final int CHANCE = 750; // 1/500 chance, average of 500 ticks (roughly 5 minutes) before a random will spawn.
/**
* Whether randoms are disabled for this player
*/
public boolean isDisabled;
/**
* The list of anti-macro events.
*/
public static final Map<String, AntiMacroEvent> EVENTS = new HashMap<>();
/**
* The player.
*/
private final Player player;
/**
* The time at which the next series of attempts to spawn a random will occur. Usually GameWorld.getTicks() + DELAY
*/
private int nextPulse;
/**
* The current event.
*/
private RandomEventNPC event;
public ExperienceMonitor[] monitors = new ExperienceMonitor[Skills.SKILL_NAME.length];
/**
* Constructs a new {@code AntiMacroHandler} {@code Object}.
* @param player The player.
*/
public AntiMacroHandler(Player player) {
this.player = player;
}
/**
* Gets called every game pulse.
*/
public void pulse() {
if (GameWorld.getTicks() < nextPulse) {
return;
}
if (!player.getLocks().isInteractionLocked() && !player.getLocks().isTeleportLocked() && !player.getLocks().isMovementLocked() && !isDisabled && !player.isArtificial()) {
int roll = RandomFunction.random(0,CHANCE);
int neededRoll = 1 + (CHANCE - RandomFunction.random(CHANCE - 10));
boolean spawnEvent = roll == neededRoll; //checks if the chance is hit this tick
//SystemLogger.log("roll: " + roll + " needed roll: " + neededRoll);
int highestIndex = 0;
int highestAmount = 0;
if(spawnEvent){
SystemLogger.logInfo("Anti-Macro: Trying to get event for " + player.getUsername());
for(int i = 0; i < monitors.length; i++){
try {
if (monitors[i].getExperienceAmount() > highestAmount) {
highestIndex = i;
highestAmount = monitors[i].getExperienceAmount();
monitors[i].setExperienceAmount(0);
}
} catch (Exception e){}
}
fireEvent(highestIndex);
}
}
}
/**
* Initializes the anti macro event handler.
*/
public void init() {
isDisabled = player.getAttribute("randoms:disabled",false);
if(isDisabled){
nextPulse = -1;
return;
} else {
nextPulse = GameWorld.getTicks() + DELAY;
}
if(!player.isArtificial() && !isDisabled) {
SystemLogger.logInfo("Anti-Macro: Initialized anti-macro handler for " + player.getUsername());
}
}
/**
* Registers a new anti-macro event.
* @param event The event.
*/
public static void register(AntiMacroEvent event) {
event.register();
EVENTS.put(event.getName(), event);
}
/**
* Checks if the npc is part of the event.
* @param npc the npc.
* @return {@code True} if so.
* @param message the message.
*/
public boolean isNPC(NPC npc, boolean message) {
if (!hasEvent()) {
if (message) {
player.getPacketDispatch().sendMessage("They don't seem interested in talking to you.");
}
return false;
}
AntiMacroNPC n = (AntiMacroNPC) npc;
/*if (n.getEvent() != event) {
if (message) {
player.getPacketDispatch().sendMessage("They don't seem interested in talking to you.");
}
return false;
}*/
return true;
}
/**
* Fires an anti-macro event.
* @param name The name of the event to start.
* @param args The arguments.
* @return {@code True} if the event has been fired.
*/
public boolean fireEvent(String name, Object... args) {
nextPulse = GameWorld.getTicks() + DELAY;
if(WildernessZone.isInZone(player)){
return false;
}
if (hasEvent() || player.getZoneMonitor().isRestricted(ZoneRestriction.RANDOM_EVENTS) || player.isArtificial()) {
return false;
}
AntiMacroEvent event = EVENTS.get(name);
if (event == null) {
if (GameWorld.getSettings().isDevMode()) {
throw new IllegalArgumentException("Could not find event " + name + "!");
} else {
return false;
}
}
event = event.create(player);
if (!event.start(player, false, args)) {
return false;
}
//resetTrigger();
//this.event = event;
return true;
}
/**
* Fires an event.
* @param skillId The skill id, -1 for default events..
* @param args The arguments.
* @return {@code True} if the event has been fired.
*/
public boolean fireEvent(int skillId, Object... args) {
/*nextPulse = DELAY + GameWorld.getTicks();
if (hasEvent() || EVENTS.isEmpty() || player.getZoneMonitor().isRestricted(ZoneRestriction.RANDOM_EVENTS) || player.isArtificial()) {
return false;
}
event = getRandomEvent(skillId);
if (event != null) {
if ((event = event.create(player)).start(player, false, args)) {
if(event == null) return true;
System.out.println("Anti-Macro: Firing event " + event.getName() + " for player: " + player.getUsername());
//resetTrigger();
return true;
}
event = null;
}*/
return false;
}
/**
* Gets an anti marco event.
* @param skillId the skillId.
* @return {@code AntiMacroEvent} the event.
*/
public AntiMacroEvent getRandomEvent(int skillId) {
int index = RandomFunction.random(EVENTS.size());
int count = 0;
AntiMacroEvent event = null;
AntiMacroEvent[] events = EVENTS.values().toArray(new AntiMacroEvent[EVENTS.size()]);
while (!(event = events[index]).canFire(skillId)) {
if (count++ >= events.length) {
event = null;
break;
}
index = (index + 1) % events.length;
}
return event;
}
/**
* Checks if the player has an anti-macro event running.
* @return {@code True} if so.
*/
public boolean hasEvent() {
return event != null;
}
/**
* Gets the player.
* @return The player.
*/
public Player getPlayer() {
return player;
}
/**
* Gets the event.
* @return The event.
*/
public RandomEventNPC getEvent() {
return event;
}
/**
* Sets the event.
* @param event The event to set.
*/
public void setEvent(RandomEventNPC event) {
this.event = event;
}
}

View file

@ -1,237 +0,0 @@
package core.game.content.ame;
import core.game.interaction.MovementPulse;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.CombatStyle;
import core.game.node.entity.npc.AbstractNPC;
import core.game.node.entity.player.Player;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.map.path.Pathfinder;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Plugin;
/**
* Handles an anti macro npc.
* @author Vexia
*/
public abstract class AntiMacroNPC extends AbstractNPC {
/**
* The player.
*/
protected final Player player;
/**
* The anti macro event.
*/
protected final AntiMacroEvent event;
/**
* The quotes the npc will say(null if none)
*/
private String[] quotes;
/**
* The counter representing speech cycles.
*/
private int count;
/**
* The time until the next speech.
*/
private int nextSpeech;
/**
* If the players time is up.
*/
protected boolean timeUp;
/**
* The end time.
*/
private int endTime;
/**
* Constructs a new {@code AntiMacroNPC} {@code Object}.
* @param id the id.
* @param location the location.
* @param player the player.
*/
public AntiMacroNPC(int id, Location location, AntiMacroEvent event, Player player, String... quotes) {
super(id, location);
this.event = event;
this.player = player;
this.quotes = quotes;
this.endTime = (int) (GameWorld.getTicks() + (1000 / 0.6));
}
@Override
public void init() {
if (event == null) {
super.clear();
return;
}
location = RegionManager.getSpawnLocation(player, this);
if (location == null) {
clear();
event.terminate();
return;
}
super.init();
startFollowing();
}
@Override
public void handleTickActions() {
if (GameWorld.getTicks() > endTime) {
clear();
}
if (!getLocks().isMovementLocked()) {
if (dialoguePlayer == null || !dialoguePlayer.isActive() || !dialoguePlayer.getInterfaceManager().hasChatbox()) {
dialoguePlayer = null;
}
}
if (!player.isActive() || !getLocation().withinDistance(player.getLocation(), 10)) {
handlePlayerLeave();
}
if (!getPulseManager().hasPulseRunning()) {
startFollowing();
}
if (quotes != null) {
if (nextSpeech < GameWorld.getTicks() && this.getDialoguePlayer() == null && !this.getLocks().isMovementLocked()) {
if (count > quotes.length - 1) {
return;
}
sendChat(quotes[count].replace("@name", player.getUsername()).replace("@gender", event.getGenderPrefix()).replace("@gL", event.getGenderPrefix().toLowerCase()));
nextSpeech = (int) (GameWorld.getTicks() + (20 / 0.5));
if (++count >= quotes.length) {
setTimeUp(true);
handleTimeUp();
return;
}
}
}
}
/**
* Called when the player is gone.
*/
public void handlePlayerLeave() {
clear();
}
/**
* Called when the quotes are finished.
*/
public void handleTimeUp() {
teleport();
}
@Override
public boolean isAttackable(Entity entity, CombatStyle style) {
if (entity instanceof Player && entity != player) {
((Player) entity).getPacketDispatch().sendMessage("It's not after you.");
return false;
}
return super.isAttackable(entity, style);
}
@Override
public void onRegionInactivity() {
super.onRegionInactivity();
clear();
}
@Override
public void clear() {
super.clear();
if (event != null) {
event.terminate();
}
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return null;
}
/**
* Teleports the player away.
*/
public void teleport() {
player.lock();
GameWorld.getPulser().submit(new Pulse(1, player) {
int count;
@Override
public boolean pulse() {
switch (++count) {
case 1:
clear();
player.getProperties().setTeleportLocation(AntiMacroEvent.getRandomLocation());
break;
case 2:
player.unlock();
event.noteItems();
player.graphics(Graphics.create(86));
return true;
}
return false;
}
});
}
/**
* Starts following the player.
*/
public void startFollowing() {
getPulseManager().run(new MovementPulse(this, player, Pathfinder.DUMB) {
@Override
public boolean pulse() {
return false;
}
}, "movement");
face(player);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
return super.newInstance(arg);
}
/**
* Gets the player.
* @return The player.
*/
public Player getPlayer() {
return player;
}
/**
* Gets the event.
* @return The event.
*/
public AntiMacroEvent getEvent() {
return event;
}
/**
* Gets the timeUp.
* @return The timeUp.
*/
public boolean isTimeUp() {
return timeUp;
}
/**
* Sets the timeUp.
* @param timeUp The timeUp to set.
*/
public void setTimeUp(boolean timeUp) {
this.timeUp = timeUp;
}
}

View file

@ -1,50 +0,0 @@
package core.game.content.ame;
/**
* Used to monitor experience gain.
* @author Emperor
*/
public final class ExperienceMonitor {
/**
* The skill id.
*/
private final int skillId;
/**
* The amount of experience gained since the last monitor pulse.
*/
private int experienceAmount;
/**
* Constructs a new {@code ExperienceMonitor} {@code Object}.
* @param skillId The skill id.
*/
public ExperienceMonitor(int skillId) {
this.skillId = skillId;
}
/**
* Gets the experienceAmount.
* @return The experienceAmount.
*/
public int getExperienceAmount() {
return experienceAmount;
}
/**
* Sets the experienceAmount.
* @param experienceAmount The experienceAmount to set.
*/
public void setExperienceAmount(int experienceAmount) {
this.experienceAmount = experienceAmount;
}
/**
* Gets the skillId.
* @return The skillId.
*/
public int getSkillId() {
return skillId;
}
}

View file

@ -1,103 +0,0 @@
package core.game.content.ame.events.drilldemon;
import java.nio.ByteBuffer;
import core.game.content.ame.AntiMacroEvent;
import core.game.interaction.Option;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.update.flag.context.Graphics;
import rs09.plugin.PluginManager;
/**
* Handles the drill demon event.
* @author Vexia
*/
public final class DrillDemonEvent extends AntiMacroEvent {
/**
* Constructs a new {@code DrillDemonEvent} {@code Object}.
*/
public DrillDemonEvent() {
this(null);
}
/**
* Constructs a new {@code DrillDemonEvent} {@code Object}.
*/
public DrillDemonEvent(Player player) {
super("drill demon", false, false);
this.player = player;
}
@Override
public boolean start(Player player, boolean login, Object... args) {
if (login) {
return true;
}
final NPC sergeant = NPC.create(2790, player.getLocation());
if (!initSergeant(sergeant)) {
return false;
}
player.lock(4);
sergeant.lock(4);
sergeant.face(player);
player.graphics(Graphics.create(86), 3);
sergeant.sendChat("Private " + player.getUsername() + "! Get yourself to the parade ground ASAP!");
GameWorld.getPulser().submit(new Pulse(3, player, sergeant) {
@Override
public boolean pulse() {
return true;
}
});
return true;
}
@Override
public AntiMacroEvent create(Player player) {
return new DrillDemonEvent(player);
}
@Override
public boolean interact(Entity e, Node target, Option option) {
return super.interact(e, target, option);
}
/**
* Initializes the sergeant (temporary).
* @param sergeant the sergeant.
* @return {@code True} if so.
*/
private boolean initSergeant(NPC sergeant) {
final Location start = RegionManager.getSpawnLocation(player, sergeant);
if (start == null) {
terminate();
return false;
}
sergeant.setLocation(start);
sergeant.init();
return true;
}
@Override
public void register() {
PluginManager.definePlugin(new SergeantDamienNPC());
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
}

View file

@ -1,67 +0,0 @@
package core.game.content.ame.events.drilldemon;
import core.game.node.entity.npc.AbstractNPC;
import core.game.world.map.Location;
import core.plugin.Plugin;
/**
* Handles the sergeant damien npc.
* @author Vexia
*/
public final class SergeantDamienNPC extends AbstractNPC {
/**
* The default spawn.
*/
private static final Location DEFAULT_SPAWN = Location.create(3163, 4818, 0);
/**
* The movement path.
*/
private static final Location[] MOVEMENT_PATH = new Location[] { Location.create(3163, 4818, 0), Location.create(3162, 4818, 0), Location.create(3161, 4818, 0), Location.create(3160, 4818, 0), Location.create(3159, 4818, 0), Location.create(3159, 4819, 0), Location.create(3159, 4820, 0), Location.create(3159, 4821, 0), Location.create(3159, 4822, 0), Location.create(3160, 4822, 0), Location.create(3161, 4822, 0), Location.create(3162, 4822, 0), Location.create(3163, 4822, 0), Location.create(3164, 4822, 0), Location.create(3165, 4822, 0), Location.create(3166, 4822, 0), Location.create(3167, 4822, 0), Location.create(3167, 4821, 0), Location.create(3167, 4820, 0), Location.create(3167, 4819, 0), Location.create(3167, 4818, 0), Location.create(3166, 4818, 0), Location.create(3165, 4818, 0), Location.create(3164, 4818, 0) };
/**
* Constructs a new {@code SergeantDamienNPC} {@code Object}.
*/
public SergeantDamienNPC() {
super(2790, DEFAULT_SPAWN);
}
/**
* Constructs a new {@code SergeantDamienNPC} {@code Object}.
* @param id the id.
* @param location the location.
*/
public SergeantDamienNPC(int id, Location location) {
super(id, location);
}
@Override
public void configure() {
super.configure();
setWalks(true);
if (isWalks()) {
configureMovementPath(MOVEMENT_PATH);
}
}
@Override
public void setNextWalk() {
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return new SergeantDamienNPC(id, location);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
init();
return super.newInstance(arg);
}
@Override
public int[] getIds() {
return new int[] { 2790 };
}
}

View file

@ -1,117 +0,0 @@
package core.game.content.ame.events.drunkdwarf;
import java.nio.ByteBuffer;
import core.game.content.ame.AntiMacroDialogue;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.dialogue.DialoguePlugin;
import core.game.content.dialogue.FacialExpression;
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.plugin.Initializable;
import rs09.plugin.PluginManager;
/**
* Handles the drunken dward anti macro event.
* @author Vexia
*/
@Initializable
public final class DrunkDwarfEvent extends AntiMacroEvent {
/**
* The name of the drunken dwarf event.
*/
public static final String NAME = "drunk dwarf";
/**
* Constructs a new {@code DrunkDwarfEvent} {@code Object}.
*/
public DrunkDwarfEvent() {
super(NAME, true, false);
}
@Override
public boolean start(Player player, boolean login, Object... args) {
final DrunkenDwarfNPC dwarf = new DrunkenDwarfNPC(956, player.getLocation(), this, player);
dwarf.init();
super.init(player);
return true;
}
@Override
public AntiMacroEvent create(Player player) {
DrunkDwarfEvent event = new DrunkDwarfEvent();
event.player = player;
return event;
}
@Override
public void register() {
PluginManager.definePlugin(new DrunkDwarfDialogue());
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
/**
* Handles the drunk dwarf dialogue.
* @author Vexia
*/
public final class DrunkDwarfDialogue extends AntiMacroDialogue {
/**
* Constructs a new {@code DrunkDwarfDialogue} {@code Object}.
*/
public DrunkDwarfDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code DrunkDwarfDialogue} {@code Object}.
* @param player the player.
*/
public DrunkDwarfDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new DrunkDwarfDialogue(player);
}
@Override
public boolean open(Object... args) {
if (super.open(args)) {
player.getDialogueInterpreter().sendDialogues(npc, FacialExpression.OLD_NORMAL, "I 'new it were you matey! 'Ere, have some ob the good", "stuff!");
} else {
return true;
}
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
wave(Animation.create(105));
player.getInventory().add(new Item(1917), player);
player.getInventory().add(new Item(1971), player);
return true;
}
@Override
public int[] getIds() {
return new int[] { 956 };
}
}
}

View file

@ -1,67 +0,0 @@
package core.game.content.ame.events.drunkdwarf;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.ame.AntiMacroNPC;
import core.game.node.entity.Entity;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.audio.Audio;
import core.game.world.map.Location;
/**
* Handles the drunken dwarf npc.
* @author Vexia
*/
public final class DrunkenDwarfNPC extends AntiMacroNPC {
/**
* The quotes that the dwarf will say.
*/
private static final String[] QUOTES = new String[] { "'Ere, matey, 'ave some 'o the good stuff.", "Dun ignore your matey!", "I hates you @name!", "Aww comeon, talk to ikle me @name!" };
/**
* Constructs a new {@code DrunkenDwarfNPC} {@code Object}.
* @param id the id.
* @param location the location.
* @param event
* @param player
*/
public DrunkenDwarfNPC(int id, Location location, AntiMacroEvent event, Player player) {
super(id, location, event, player, QUOTES);
}
@Override
public void init() {
super.init();
player.getAudioManager().send(new Audio(344));
}
@Override
public void handleTickActions() {
super.handleTickActions();
if (timeUp && getDialoguePlayer() == null) {
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(player);
}
}
}
@Override
public void handleTimeUp() {
}
@Override
public boolean isIgnoreAttackRestrictions(Entity victim) {
return true;
}
@Override
public boolean isIgnoreMultiBoundaries(Entity victim) {
return victim == player;
}
@Override
public int[] getIds() {
return new int[] { 956 };
}
}

View file

@ -1,140 +0,0 @@
package core.game.content.ame.events.evilchicken;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState;
import core.game.node.entity.combat.CombatStyle;
import core.game.node.entity.npc.AbstractNPC;
import core.game.node.entity.player.Player;
import core.game.node.item.GroundItem;
import core.game.node.item.GroundItemManager;
import core.game.node.item.Item;
import core.game.world.map.Location;
import core.game.world.update.flag.context.Graphics;
import core.tools.RandomFunction;
import rs09.game.node.entity.combat.CombatSwingHandler;
import rs09.game.node.entity.combat.handlers.MagicSwingHandler;
/**
* Handles the evil chicken NPC.
* @author Emperor
*/
public final class EvilChickenNPC extends AbstractNPC {
/**
* The messages the evil chicken can use.
*/
private static final String[] MESSAGES = { "Bwuk", "Bwuk bwuk bwuk", "Bwaaaaaauk bwuk bwuk", "How dare you invade my lair?", "MUAHAHAHAHAAA!", "Flee from me, @name@!", "Begone, @name@!" };
/**
* The player.
*/
protected Player player;
/**
* The random event instance.
*/
public EvilChickenRandomEvent event;
/**
* The combat swing handler.
*/
private static final CombatSwingHandler HANDLER = new MagicSwingHandler() {
@Override
public int swing(Entity entity, Entity victim, BattleState state) {
entity.sendChat(RandomFunction.getRandomElement(MESSAGES).replace("@name@", victim.getUsername()));
return super.swing(entity, victim, state);
}
};
/**
* Constructs a new {@code EvilChickenNPC} {@code Object}.
*/
public EvilChickenNPC() {
this(2463, null);
}
@Override
public void finalizeDeath(Entity killer) {
super.finalizeDeath(killer);
if (killer instanceof Player) {
GroundItemManager.create(new GroundItem(new Item(526), getLocation(), killer.asPlayer()));
GroundItemManager.create(new GroundItem(new Item(2138), getLocation(), killer.asPlayer()));
GroundItemManager.create(new GroundItem(new Item(314, RandomFunction.random(32, 750)), getLocation(), killer.asPlayer()));
}
}
/**
* Constructs a new {@code EvilChickenNPC} {@code Object}.
* @param id The NPC id.
* @param location The location.
*/
public EvilChickenNPC(int id, Location location) {
super(id, location);
}
@Override
public void init() {
super.init();
setRespawn(false);
graphics(Graphics.create(86));
getProperties().getCombatPulse().attack(player);
}
@Override
public void handleTickActions() {
if (player == null) {
return;
}
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(player);
}
if (!player.isActive() || !getLocation().withinDistance(player.getLocation(), 10)) {
clear();
}
}
@Override
public CombatSwingHandler getSwingHandler(boolean swing) {
return HANDLER;
}
@Override
public boolean isAttackable(Entity entity, CombatStyle style) {
if (entity instanceof Player && entity != player) {
((Player) entity).getPacketDispatch().sendMessage("It's not after you.");
return false;
}
return super.isAttackable(entity, style);
}
@Override
public boolean isIgnoreMultiBoundaries(Entity victim) {
return victim == player;
}
@Override
public void onRegionInactivity() {
super.onRegionInactivity();
clear();
}
@Override
public void clear() {
super.clear();
if (event != null) {
event.terminate();
}
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return new EvilChickenNPC(id, location);
}
@Override
public int[] getIds() {
return new int[] { 2463, 2464, 2465, 2466, 2467, 2468 };
}
}

View file

@ -1,79 +0,0 @@
package core.game.content.ame.events.evilchicken;
import java.nio.ByteBuffer;
import core.game.content.ame.AntiMacroEvent;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.HintIconManager;
import core.game.world.map.Location;
import core.plugin.Initializable;
import rs09.plugin.PluginManager;
/**
* Handles the evil chicken random event.
* @author Emperor
*/
@Initializable
public final class EvilChickenRandomEvent extends AntiMacroEvent {
/**
* Constructs a new {@code EvilChickenRandomEvent} {@code Object}.
*/
public EvilChickenRandomEvent() {
super("chicken", true, false);
}
@Override
public boolean start(Player player, boolean login, Object... args) {
super.init(player);
int level = player.getProperties().getCurrentCombatLevel();
int npcId = 2468;
if (level < 11) {
npcId = 2463;
} else if (level < 21) {
npcId = 2464;
} else if (level < 41) {
npcId = 2465;
} else if (level < 61) {
npcId = 2466;
} else if (level < 91) {
npcId = 2467;
}
Location location = Location.getRandomLocation(player.getLocation(), 6, true);
EvilChickenNPC npc = new EvilChickenNPC(npcId, location);
npc.player = player;
npc.event = this;
npc.init();
if (location == player.getLocation()) {
npc.moveStep();
}
HintIconManager.registerHintIcon(player, npc);
return true;
}
@Override
public void terminate() {
super.terminate();
if (player != null) {
player.getHintIconManager().clear();
}
}
@Override
public AntiMacroEvent create(Player player) {
EvilChickenRandomEvent event = new EvilChickenRandomEvent();
event.player = player;
return event;
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
PluginManager.definePlugin(new EvilChickenNPC());
}
}

View file

@ -1,478 +0,0 @@
package core.game.content.ame.events.eviltwin;
import java.nio.ByteBuffer;
import rs09.ServerConstants;
import core.game.component.CloseEvent;
import core.game.component.Component;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.global.action.DoorActionHandler;
import core.game.interaction.Option;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.object.GameObject;
import core.game.node.object.ObjectBuilder;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.map.Direction;
import core.game.world.map.Location;
import core.game.world.map.build.DynamicRegion;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.net.packet.PacketRepository;
import core.net.packet.context.CameraContext;
import core.net.packet.context.CameraContext.CameraType;
import core.net.packet.out.CameraViewPacket;
import rs09.plugin.PluginManager;
import core.tools.RandomFunction;
/**
* Handles the evil twin random event.
* @author Emperor
*/
public final class EvilTwinRandomEvent extends AntiMacroEvent {
/**
* The x-offset.
*/
private int offsetX = 0;
/**
* The y-offset.
*/
private int offsetY = 0;
/**
* The Molly NPC.
*/
private NPC molly;
/**
* The current crane object.
*/
private GameObject currentCrane;
/**
* The amount of tries left.
*/
private int tries = 3;
/**
* If the event has been completed.
*/
private boolean success;
/**
* The crane NPC.
*/
private NPC craneNPC;
/**
* Constructs a new {@code EvilTwinRandomEvent} {@code Object}.
*/
public EvilTwinRandomEvent() {
this(null);
}
/**
* Constructs a new {@code EvilTwinRandomEvent} {@code Object}.
* @param player The player.
*/
public EvilTwinRandomEvent(Player player) {
super("Evil twin", true, true);
super.player = player;
}
@Override
public void register() {
PluginManager.definePlugin(new MollyDialogue());
}
@Override
public boolean start(final Player player, boolean login, Object... args) {
region = DynamicRegion.create(7504);
region.setMusicId(612);
registerRegion(region.getId());
currentCrane = new GameObject(14976, region.getBaseLocation().transform(14, 12, 0), 10, 0);
if (login) {
int hash = player.getAttribute("ame:evil_twin", 0);
molly = NPC.create(getMollyId(hash), region.getBaseLocation().transform(4, 15, 0));
molly.init();
spawnSuspects(hash);
toggleVisibleNPCs(player.getLocation().getLocalX() < 9);
player.getProperties().setTeleportLocation(region.getBaseLocation().transform(offsetX, offsetY, 0));
return true;
}
TwinClothColor color = RandomFunction.getRandomElement(TwinClothColor.values());
int model = RandomFunction.random(5);
final int hash = color.ordinal() | (model << 16);
player.setAttribute("ame:evil_twin", hash);
int npcId = getMollyId(hash);
molly = NPC.create(npcId, Location.getRandomLocation(player.getLocation(), 2, true));
molly.init();
molly.graphics(Graphics.create(86, 96));
molly.sendChat("I need your help, " + player.getUsername() + ".");
molly.face(player);
player.lock(4);
player.setAttribute("ame:location", player.getLocation());
GameWorld.getPulser().submit(new Pulse(3) {
@Override
public boolean pulse() {
teleport(player, molly, hash);
return true;
}
});
return true;
}
@Override
public boolean enter(Entity entity) {
if (entity instanceof Player) {
((Player) entity).getInterfaceManager().hideTabs(0, 1, 2, 3, 4, 5, 6, 7, 11, 12);
}
return super.enter(entity);
}
@Override
public boolean leave(Entity e, boolean logout) {
if (e == player) {
if (!logout) {
terminate();
}
player.removeAttribute("ame:evil_twin:ccx");
player.removeAttribute("ame:evil_twin:ccy");
}
return super.leave(e, logout);
}
@Override
public void terminate() {
super.terminate();
craneNPC = null;
if (player != null) {
player.getInterfaceManager().restoreTabs();
player.removeAttribute("ame:location");
player.removeAttribute("ame:evil_twin_info");
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.RESET, 0, 0, 0, 0, 0));
}
}
@Override
public boolean interact(Entity e, Node target, Option option) {
if (target instanceof GameObject) {
GameObject object = (GameObject) target;
switch (object.getId()) {
case 14982:
if (e.getLocation().getLocalX() < 9 && !e.getAttribute("ame:evil_twin_info", false)) {
player.getDialogueInterpreter().open("ame:molly", molly, 3);
return true;
}
DoorActionHandler.handleAutowalkDoor(e, object);
return true;
case 14978:
if (success) {
player.getPacketDispatch().sendMessage("You already caught the evil twin.");
return true;
}
player.getInterfaceManager().openSingleTab(new Component(240).setCloseEvent(new CloseEvent() {
@Override
public boolean close(Player player, Component c) {
ObjectBuilder.remove(currentCrane);
ObjectBuilder.add(new GameObject(66, currentCrane.getLocation(), 22, 0));
currentCrane = currentCrane.transform(currentCrane.getId(), currentCrane.getRotation(), region.getBaseLocation().transform(14, 12, 0));
ObjectBuilder.add(new GameObject(14977, currentCrane.getLocation(), 22, 0));
ObjectBuilder.add(currentCrane);
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.RESET, 0, 0, 0, 0, 0));
return true;
}
}));
player.getPacketDispatch().sendString("Tries: " + tries, 240, 27);
updateCraneCam(14, 12);
return true;
}
} else if (target instanceof NPC) {
NPC npc = (NPC) target;
if ((tries < 1 || success) && npc.getId() >= 3892 && npc.getId() <= 3911) {
player.getDialogueInterpreter().open("ame:molly", npc, success ? 2 : 1);
return true;
}
}
return false;
}
@Override
public boolean actionButton(final Player player, int interfaceId, int buttonId, int slot, int itemId, int opcode) {
if (success) {
return false;
}
switch (interfaceId) {
case 240:
switch (buttonId) {
case 28:
player.lock(5);
player.getLocks().lockComponent(5);
success = false;
for (final NPC npc : region.getPlanes()[0].getNpcs()) {
if (npc.getLocation().equals(currentCrane.getLocation())) {
final boolean evilTwin = isEvilTwin(npc, player.getAttribute("ame:evil_twin", 0));
if (evilTwin) {
success = true;
player.getPacketDispatch().sendMessage("You caught the Evil twin!");
} else {
player.getPacketDispatch().sendMessage("You caught an innocent civilian!");
}
npc.animate(Animation.create(4001));
npc.lock(10);
player.lock(10);
player.getLocks().lockComponent(15);
updateCraneCam(10, 4);
GameWorld.getPulser().submit(new Pulse(5, player) {
int cycle = 0;
@Override
public boolean pulse() {
switch (cycle++) {
case 0:
ObjectBuilder.remove(currentCrane);
ObjectBuilder.add(new GameObject(66, currentCrane.getLocation(), 22, 0));
npc.transform(npc.getId() + 20);
npc.lock(20);
npc.getWalkingQueue().reset();
npc.getWalkingQueue().addPath(region.getBaseLocation().getX() + 10, region.getBaseLocation().getY() + 4);
setDelay(npc.getWalkingQueue().getQueue().size() + 1);
craneNPC = npc;
break;
case 1:
craneNPC = null;
npc.animate(Animation.create(4003));
setDelay(3);
break;
case 2:
npc.reTransform();
npc.faceLocation(player.getLocation());
if (evilTwin) {
removeSuspects();
npc.getAnimator().forceAnimation(Animation.create(859));
} else {
npc.sendChat("You're putting me in prison?!");
}
currentCrane = currentCrane.transform(currentCrane.getId(), currentCrane.getRotation(), region.getBaseLocation().transform(14, 12, 0));
ObjectBuilder.add(new GameObject(14977, currentCrane.getLocation(), 22, 0));
ObjectBuilder.add(currentCrane);
break;
case 3:
updateCraneCam(14, 12);
if (evilTwin) {
player.getInterfaceManager().closeSingleTab();
player.getDialogueInterpreter().open("ame:molly", molly, 0);
} else {
decreaseTries();
}
return true;
}
return false;
}
});
player.getPacketDispatch().sendObjectAnimation(currentCrane, Animation.create(4000));
return true;
}
}
decreaseTries();
player.getPacketDispatch().sendObjectAnimation(currentCrane, Animation.create(4000));
return true;
case 29:
moveCrane(Direction.SOUTH);
return true;
case 30:
moveCrane(Direction.NORTH);
return true;
case 31:
moveCrane(Direction.EAST);
return true;
case 32:
moveCrane(Direction.WEST);
return true;
case 34:
player.getInterfaceManager().closeSingleTab();
return true;
}
break;
}
return false;
}
/**
* Decreases the tries amount.
*/
public void decreaseTries() {
tries--;
player.getPacketDispatch().sendString("Tries: " + tries, 240, 27);
if (tries < 1) {
player.lock(20);
player.getInterfaceManager().closeSingleTab();
player.getDialogueInterpreter().open("ame:molly", molly, 1);
}
}
@Override
public void locationUpdate(Entity e, Location last) {
if (e == craneNPC && e.getWalkingQueue().getQueue().size() > 1 && player.getInterfaceManager().getSingleTab() != null) {
Location l = e.getLocation();
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.POSITION, l.getX() + 2, l.getY() + 3, 650, 1, 5));
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.ROTATION, l.getX() - 3, l.getY() - 3, 420, 1, 5));
} else if (e == player) {
if (molly.isInvisible() && e.getLocation().getLocalX() < 9) {
toggleVisibleNPCs(true);
} else if (!molly.isInvisible() && e.getLocation().getLocalX() > 8) {
toggleVisibleNPCs(false);
}
}
super.locationUpdate(e, last);
}
/**
* Toggles the visibility of the NPCs.
* @param showMolly If molly should be shown.
*/
public void toggleVisibleNPCs(boolean showMolly) {
for (NPC npc : region.getPlanes()[0].getNpcs()) {
if (npc.getId() >= 3852 && npc.getId() <= 3891) {
npc.setInvisible(showMolly);
}
}
molly.setInvisible(!showMolly);
}
/**
* Method used to handle the camera.
* @param x the x offset.
* @param y the y offset.
* @Param height the height.
*/
private void updateCraneCam(int x, int y) {
if (player.getInterfaceManager().getSingleTab() != null) {
Location loc = region.getBaseLocation().transform(14, 20, 0);
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.POSITION, loc.getX(), loc.getY(), 650, 1, 100));
loc = region.getBaseLocation().transform(x, 4 + y - (x < 14 || x > 14 ? (y / 4) : 0), 0);
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.ROTATION, loc.getX(), loc.getY(), 420, 1, 100));
}
player.setAttribute("ame:evil_twin:ccx", x);
player.setAttribute("ame:evil_twin:ccy", y);
}
/**
* Removes the suspects.
*/
public void removeSuspects() {
int hash = player.getAttribute("ame:evil_twin", 0);
for (final NPC npc : region.getPlanes()[0].getNpcs()) {
if (npc.getId() >= 3852 && npc.getId() <= 3891 && !isEvilTwin(npc, hash)) {
Graphics.send(Graphics.create(86), npc.getLocation());
npc.clear();
}
}
}
/**
* Checks if the NPC is the evil twin NPC.
* @param npc The NPC.
* @return {@code True} if so.
*/
private boolean isEvilTwin(NPC npc, int hash) {
int npcId = npc.getId() - 3852;
int type = npcId / TwinClothColor.values().length;
int color = npcId - (type * TwinClothColor.values().length);
return hash == (color | (type << 16));
}
/**
* Moves the crane.
* @param direction The current direction.
*/
private void moveCrane(final Direction direction) {
GameWorld.getPulser().submit(new Pulse(1, player) {
@Override
public boolean pulse() {
if (!direction.canMove(currentCrane.getLocation().transform(direction))) {
return true;
}
int craneX = player.getAttribute("ame:evil_twin:ccx", 14) + direction.getStepX();
int craneY = player.getAttribute("ame:evil_twin:ccy", 12) + direction.getStepY();
updateCraneCam(craneX, craneY);
ObjectBuilder.remove(currentCrane);
ObjectBuilder.add(new GameObject(66, currentCrane.getLocation(), 22, 0));
currentCrane = currentCrane.transform(currentCrane.getId(), currentCrane.getRotation(), region.getBaseLocation().transform(craneX, craneY, 0));
ObjectBuilder.add(new GameObject(14977, currentCrane.getLocation(), 22, 0));
ObjectBuilder.add(currentCrane);
return true;
}
});
}
@Override
public boolean teleport(Entity e, int type, Node node) {
if (type != -1) {
if (e instanceof Player) {
((Player) e).getPacketDispatch().sendMessage("You can't teleport away from here.");
}
return false;
}
return true;
}
/**
* Spawns the suspects.
* @param hash The color & type.
*/
public void spawnSuspects(int hash) {
if (region.getPlanes()[0].getNpcs().size() > 3) {
return;
}
int npcId = 3852 + (hash & 0xFF);
for (int i = 0; i < 5; i++) {
Location location = region.getBaseLocation().transform(11 + RandomFunction.random(8), 6 + RandomFunction.random(6), 0);
NPC suspect = NPC.create(npcId + (i * TwinClothColor.values().length), location);
suspect.setWalks(true);
suspect.setWalkRadius(6);
suspect.init();
}
}
/**
* Teleports the player and Molly to the random event region.
* @param player The player.
* @param npc The NPC.
*/
public void teleport(Player player, NPC npc, int hash) {
npc.getProperties().setTeleportLocation(region.getBaseLocation().transform(4, 15, 0));
player.getProperties().setTeleportLocation(region.getBaseLocation().transform(4, 16, 0));
player.getDialogueInterpreter().open(npc.getId(), npc);
spawnSuspects(hash);
toggleVisibleNPCs(true);
}
/**
* Gets the current NPC id for Molly.
* @return The NPC id.
*/
public static int getMollyId(int hash) {
return 3892 + (hash & 0xFF) + (((hash >> 16) & 0xFF) * TwinClothColor.values().length);
}
@Override
public AntiMacroEvent create(Player player) {
return new EvilTwinRandomEvent(player);
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
}

View file

@ -1,156 +0,0 @@
package core.game.content.ame.events.eviltwin;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.dialogue.DialogueInterpreter;
import core.game.content.dialogue.DialoguePlugin;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.TeleportManager.TeleportType;
import core.game.node.item.GroundItemManager;
import core.game.node.item.Item;
import core.game.system.script.ScriptContext;
import core.game.system.script.ScriptManager;
import core.game.world.map.Location;
import core.tools.RandomFunction;
/**
* Handles Molly's dialogue.
* @author Emperor
*/
public final class MollyDialogue extends DialoguePlugin {
/**
* The possible rewards.
*/
private static final Item[] REWARDS = { new Item(1618, 2), new Item(1620, 3), new Item(1622, 3), new Item(1624, 4), };
/**
* If the player successfully caught the evil twin.
*/
private int type;
/**
* Constructs a new {@code MollyDialogue} {@code Object}.
*/
public MollyDialogue() {
super();
}
/**
* Constructs a new {@code MollyDialogue} {@code Object}.
* @param player The player.
*/
public MollyDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new MollyDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
type = (Integer) args[1];
if (type == 0) {
player.getPacketDispatch().sendMessage("Congratulations! You caught the evil twin!");
npc("Well done! You managed to catch my sister!");
} else if (type == 1) {
npc("Such incompetence! I should never have asked a", "baboon like you to do a complex task like this!", "Get out of my sight!");
} else if (type == 2) {
player("Well, I've managed to get her into the cage.");
} else if (type == 3) {
npc("Wait! Do you know what you're doing here?");
}
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage++) {
case 0:
switch (type) {
case 0:
npc("Come next door and talk to me.");
return true;
case 1:
player("Err, sorry. I seem to have messed it up a little.");
return true;
case 2:
npc("Fantastic! For so many years I've had to put up with", "her and now she's locked up for good.");
return true;
case 3:
options("Yes, I know.", "Erm, no I don't actually.");
return true;
}
break;
case 1:
switch (type) {
case 0:
end();
return true;
case 1:
player.getTeleporter().send(AntiMacroEvent.getRandomLocation(), TeleportType.NORMAL, -1);
end();
return true;
case 2:
npc("Thank you for all your help. Take this as a reward.");
return true;
case 3:
switch (buttonId) {
case 1:
player.setAttribute("/save:ame:evil_twin_info", true);
player("Yes, I know, I've been here before.");
stage = 10;
return true;
case 2:
stage = 20;
player("Erm, no I don't actually.");
return true;
}
break;
}
break;
case 2:
switch (type) {
case 2:
end();
Location destination = player.getAttribute("ame:location");
if (destination != null) {
Item item = RandomFunction.getRandomElement(REWARDS);
if (player.getInventory().hasSpaceFor(item)) {
player.getInventory().add(item);
} else {
GroundItemManager.create(item, destination, player);
}
player.getDialogueInterpreter().sendItemMessage(item, "Molly's given you " + item.getAmount() + " " + item.getName().toLowerCase() + "s.");
player.getProperties().setTeleportLocation(destination);
player.removeAttribute("ame:location");
}
return true;
}
break;
case 10:
npc("Good luck!");
break;
case 11:
end();
break;
case 20:
end();
ScriptContext script = DialogueInterpreter.getScript(npc.getId());
if (script != null && (script = ScriptManager.getMethod(script, "event_info")) != null) {
player.getDialogueInterpreter().startScript(npc.getId(), script, player, npc);
}
break;
}
return false;
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("ame:molly") };
}
}

View file

@ -1,10 +0,0 @@
package core.game.content.ame.events.eviltwin;
/**
* The clothing colors.
* @author Emperor
*/
public enum TwinClothColor {
RED, GREEN, BLUE, YELLOW;
}

View file

@ -1,48 +0,0 @@
package core.game.content.ame.events.genie;
import core.game.content.ame.AntiMacroNPC;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
import core.game.world.update.flag.context.Graphics;
/**
* Handles the random event genie npc.
* @author Vexia
*/
public final class GenieNPC extends AntiMacroNPC {
/**
* The force chats to pronounce.
*/
private static final String[] CHATS = new String[] { "Greetings, @gL @name!", "Ehem... @gender @name?", "Are you there, @gL @name?", "No one ignores me!" };
/**
* Constructs a new {@code GenieNPC} {@code Object}.
* @param id the id.
* @param location the location.
* @param event the event.
* @param player the player.
*/
public GenieNPC(int id, Location location, GenieRandomEvent event, Player player) {
super(id, location, event, player, CHATS);
}
/**
* Constructs a new {@code GenieNPC} {@code Object}.
*/
public GenieNPC() {
super(0, null, null, null);
}
@Override
public void init() {
super.init();
graphics(new Graphics(86));
}
@Override
public int[] getIds() {
return new int[] { 409 };
}
}

View file

@ -1,124 +0,0 @@
package core.game.content.ame.events.genie;
import core.game.content.ame.AntiMacroDialogue;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.dialogue.DialoguePlugin;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.game.world.map.Location;
import core.plugin.Initializable;
import rs09.plugin.PluginManager;
/**
* Handles the genie random event.
* @author Vexia
*/
@Initializable
public final class GenieRandomEvent extends AntiMacroEvent {
/**
* The lamp item.
*/
private static final Item LAMP = new Item(2528);
/**
* Constructs a new {@code GenieRandomEvent} {@code Object}.
*/
public GenieRandomEvent() {
super("Genie", true, false);
}
@Override
public boolean start(Player player, boolean login, Object... args) {
if (player.hasItem(new Item(2528))) {
return false;
}
super.init(player);
final GenieNPC npc = new GenieNPC(409, player.getLocation(), this, player);
npc.init();
return true;
}
@Override
public AntiMacroEvent create(Player player) {
final GenieRandomEvent event = new GenieRandomEvent();
event.player = player;
return event;
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
@Override
public void register() {
PluginManager.definePlugin(new GenieDialogue());
}
@Override
public String getGenderPrefix(boolean male) {
return male ? "Master" : "Mistress";
}
/**
* Handles the dialogue used for the genie npc.
* @author Vexia
*/
public final class GenieDialogue extends AntiMacroDialogue {
/**
* Constructs a new {@code GenieDialogue} {@code Object}.
*/
public GenieDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code GenieDialogue} {@code Object}.
* @param player the player.
*/
public GenieDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new GenieDialogue(player);
}
@Override
public boolean open(Object... args) {
if (super.open(args)) {
}
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
npc("I hope you're happy with your wish. I must be leaving", "now, though.");
stage++;
break;
case 1:
wave();
player.getInventory().add(LAMP, player);
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 409 };
}
}
}

View file

@ -1,185 +0,0 @@
package core.game.content.ame.events.lostandfound;
import java.nio.ByteBuffer;
import rs09.ServerConstants;
import core.cache.def.impl.ObjectDefinition;
import core.game.content.ame.AntiMacroEvent;
import core.game.interaction.Option;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.TeleportManager;
import core.game.node.item.Item;
import core.game.node.object.GameObject;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.map.Location;
import core.net.packet.PacketRepository;
import core.net.packet.context.MinimapStateContext;
import core.net.packet.out.MinimapState;
import core.plugin.Plugin;
import rs09.plugin.PluginManager;
import core.tools.RandomFunction;
/**
* Handles the "Lost and found" random event.
* @author Emperor
*/
public final class LostFoundRandomEvent extends AntiMacroEvent {
/**
* Constructs a new {@code LostFoundRandomEvent} {@code Object}.
*/
public LostFoundRandomEvent() {
this(null);
}
/**
* Constructs a new {@code LostFoundRandomEvent} {@code Object}.
* @param player The player.
*/
public LostFoundRandomEvent(Player player) {
super("landf", false, true, -1);
super.player = player;
}
@Override
public boolean start(Player player, boolean login, Object... args) {
player.getProperties().setTeleportLocation(Location.create(2338, 4747, 0));
if (player.getAttribute("l&f_dest") == null) {
player.setAttribute("l&f_dest", args.length > 0 ? args[0] : player.getLocation());
}
player.sendChat("Uh? Help!");
return true;
}
@Override
public boolean enter(Entity entity) {
if (entity instanceof Player) {
Player player = (Player) entity;
setRandomAppendage(player);
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 2));
player.getDialogueInterpreter().sendPlainMessage(false, "There has been a fault in the teleportation matrix. Please operate the", "odd appendage out to be forwarded to your destination.");
}
return super.enter(entity);
}
@Override
public boolean leave(Entity entity, boolean logout) {
if (entity instanceof Player && !logout) {
Player player = (Player) entity;
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0));
player.removeAttribute("l&f_dest");
player.removeAttribute("teleport:items");
player.getLocks().unlock();
player.getAntiMacroHandler().setEvent(null);
}
return super.leave(entity, logout);
}
@Override
public boolean interact(Entity e, Node target, Option option) {
if (!(target instanceof GameObject)) {
return true;
}
return false;
}
@Override
public boolean actionButton(Player player, int interfaceId, int buttonId, int slot, int itemId, int opcode) {
return false;
}
@Override
public boolean teleport(Entity e, int type, Node node) {
if (type != -1) {
if (e instanceof Player) {
((Player) e).getPacketDispatch().sendMessage("You have to operate the appendage before you can teleport again.");
}
return false;
}
return true;
}
@Override
public AntiMacroEvent create(Player player) {
return new LostFoundRandomEvent(player);
}
@Override
public Location getSpawnLocation() {
return null;
}
/**
* Sets a random odd appendage.
* @param player The player.
*/
private static void setRandomAppendage(Player player) {
int value = 0;
int odd = RandomFunction.random(4);
int mod = RandomFunction.RANDOM.nextBoolean() ? 0 : 1;
int offset = RandomFunction.random(4) * 2;
for (int i = 0; i < 4; i++) {
if (i == odd) {
value |= (offset + (1 - mod)) << (i * 5);
} else {
value |= (offset + mod) << (i * 5);
}
}
player.getConfigManager().set(531, value);
}
@Override
public void configure() {
registerRegion(9290);
PluginManager.definePlugin(new OptionHandler() {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int id = 8998; id < 9006; id++) {
ObjectDefinition.forId(id).getHandlers().put("option:operate", this);
}
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
GameObject object = (GameObject) node;
player.lock(2);
if (isOddAppendage(player, object)) {
GameWorld.getPulser().submit(new Pulse(4) {
@Override
public boolean pulse() {
player.getDialogueInterpreter().sendPlainMessage(false, "The Abyssal Services Department apologises for the inconvenience.");
return true;
}
});
player.getInventory().add(player.getAttribute("teleport:items", new Item[0]));
player.getTeleporter().send(player.getAttribute("l&f_dest", ServerConstants.HOME_LOCATION), TeleportManager.getType(player), -1);
} else {
setRandomAppendage(player);
player.getPacketDispatch().sendMessage("That was not the correct appendage!");
}
return true;
}
/**
* Checks if the object was the player's odd appendage.
* @param player The player.
* @return {@code True} if the odd appendage was operated.
*/
private boolean isOddAppendage(Player player, GameObject object) {
int index = object.getWrapper().getId() - 8994;
int current = object.getWrapper().getChild(player).getId();
for (int i = 0; i < 4; i++) {
if (index != i && ObjectDefinition.forId(8994 + i).getChildObject(player).getId() == current) {
return false;
}
}
return true;
}
});
}
}

View file

@ -1,141 +0,0 @@
package core.game.content.ame.events.lostpirate;
import java.nio.ByteBuffer;
import org.rs09.consts.Items;
import core.game.content.ame.AntiMacroDialogue;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.dialogue.DialoguePlugin;
import core.game.node.entity.npc.drop.DropFrequency;
import core.game.node.entity.player.Player;
import core.game.node.item.ChanceItem;
import core.game.node.item.Item;
import core.game.world.map.Location;
import rs09.plugin.PluginManager;
import core.plugin.Initializable;
import core.tools.RandomFunction;
/**
* Handles the capn hand anti macro event.
* @author Vexia
*/
@Initializable
public final class CapnHandEvent extends AntiMacroEvent {
/**
* The name of the event.
*/
public static final String NAME = "capn hand";
/**
* Constructs a new {@code CapnHandEvent} {@code Object}.
*/
public CapnHandEvent() {
super(NAME, true, false);
}
@Override
public boolean start(Player player, boolean login, Object... args) {
final CapnHandNPC capn = new CapnHandNPC(2539, player.getLocation(), this, player);
capn.init();
super.init(player);
return true;
}
@Override
public AntiMacroEvent create(Player player) {
CapnHandEvent event = new CapnHandEvent();
event.player = player;
return event;
}
@Override
public void register() {
PluginManager.definePlugin(new CapnHandDialogue());
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
@Override
public String getGenderPrefix(boolean male) {
return male ? "mister" : "miss";
}
/**
* Handles the rick turpnetine dialogue.
* @author Vexia
*/
public static final class CapnHandDialogue extends AntiMacroDialogue {
/**
* The random items recieved.
*/
private static final ChanceItem[] ITEMS = new ChanceItem[] {
new ChanceItem(Items.COINS_995, 1, 640, DropFrequency.COMMON),
new ChanceItem(Items.SPINACH_ROLL_1969, 1, 1, DropFrequency.COMMON),
new ChanceItem(Items.KEBAB_1971, 1, 1, DropFrequency.COMMON),
new ChanceItem(Items.UNCUT_SAPPHIRE_1623, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.UNCUT_EMERALD_1621, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.UNCUT_RUBY_1619, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.UNCUT_DIAMOND_1617, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.COSMIC_TALISMAN_1454, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.TOOTH_HALF_OF_A_KEY_985, 1, 1, DropFrequency.RARE)};
/**
* Constructs a new {@code CapnHandDialogue} {@code Object}.
*/
public CapnHandDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code CapnHandDialogue} {@code Object}.
* @param player the player.
*/
public CapnHandDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new CapnHandDialogue(player);
}
@Override
public boolean open(Object... args) {
if (super.open(args)) {
npc("My mistake " + event.getGenderPrefix() + ", I was thinking yer be some other", "fella!", "Take this swag, and we'll be saying no more about it!", "Yarrr!");
} else {
return true;
}
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
Item item = RandomFunction.getChanceItem(ITEMS).getRandomItem();
if (item.getId() == Items.TOOTH_HALF_OF_A_KEY_985 && RandomFunction.randomSign(1) <= 0) {
item = new Item(Items.LOOP_HALF_OF_A_KEY_987);
}
player.getInventory().add(item, player);
wave(null);
return true;
}
@Override
public int[] getIds() {
return new int[] { 2539 };
}
}
}

View file

@ -1,60 +0,0 @@
package core.game.content.ame.events.lostpirate;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.ame.AntiMacroNPC;
import core.game.node.entity.Entity;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
/**
* Handles the capn hand npc.
* @author Vexia
*/
public final class CapnHandNPC extends AntiMacroNPC {
/**
* The quotes to say.
*/
private static final String[] QUOTES = new String[] { "Heave to, @gender @name!", "That be an order, @gender @name!" };
/**
* Constructs a new {@code CapnHandNPC} {@code Object}.
* @param id the id.
* @param location the loc.
* @param event the event.
* @param player the player.
*/
public CapnHandNPC(int id, Location location, AntiMacroEvent event, Player player) {
super(id, location, event, player, QUOTES);
}
@Override
public void handleTickActions() {
super.handleTickActions();
if (timeUp && getDialoguePlayer() == null) {
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(player);
}
}
}
@Override
public void handleTimeUp() {
}
@Override
public boolean isIgnoreAttackRestrictions(Entity victim) {
return true;
}
@Override
public boolean isIgnoreMultiBoundaries(Entity victim) {
return victim == player;
}
@Override
public int[] getIds() {
return new int[] { 2539 };
}
}

View file

@ -1,256 +0,0 @@
package core.game.content.ame.events.quizmaster;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import core.cache.def.impl.ItemDefinition;
import core.game.content.dialogue.DialoguePlugin;
import core.game.content.dialogue.FacialExpression;
import core.game.node.entity.player.Player;
import core.game.node.item.GroundItemManager;
import core.game.node.item.Item;
import rs09.game.world.GameWorld;
import core.game.world.map.Location;
import core.net.packet.PacketRepository;
import core.net.packet.context.DisplayModelContext;
import core.net.packet.context.DisplayModelContext.ModelType;
import core.net.packet.out.DisplayModel;
import core.tools.RandomFunction;
/**
* Handles the quiz master dialogue.
* @author Vexia
*/
public final class QuizMasterDialogue extends DialoguePlugin {
/**
* The correct dialogues.
*/
private static final String[][] CORRECT = new String[][] { { "Hey, you're good at this!", "CORRECT!", "Okay, next question!" }, { "Absolutely RIGHT!", "Keep going for the win!", "Okay, next question!" }, { "Wow, you're a smart one!", "You're absolutely right!", "Okay, next question!" }, { "COR-RECT!", "Okay, next question!" }, { "DING DING DING", "That's RIGHT! Good for you!", "Okay, next question!" }, { "YES!", "You're RIGHT!", "Okay, next question!" } };
/**
* The wrong dialogues.
*/
private static final String[][] WRONG = new String[][] { { "Huh...? Didn't you know that one?", "You're supposed to pick the ODD ONE OUT.", "Now, let's start again..." }, { "No. No, that's not right at all.", "You're supposed to pick the ODD ONE OUT.", "Now let's start again..." }, { "No, sorry, Try harder!", "You're supposed to pick the ODD ONE OUT.", "Now, let's start again..." }, { "Better luck next time!", "You're supposed to pick the ODD ONE OUT.", "Now, let's start again..." }, { "WRONG! That's just WRONG!", "You're supposed to pick the ODD ONE OUT.", "Now, let's start again..." }, { "WRONG WRONG WRONG!", "You're supposed to pick the ODD ONE OUT.", "Now, let's start again..." }, { "No, no, no... That's completely WRONG!", "You're supposed to pick the ODD ONE OUT.", "Now, let's start again..." }, { "Nope, that's not it.", "You're supposed to pick the ODD ONE OUT.", "Now, let's start again..." }, { "BZZZZZZZ! WRONG!", "You're supposed to pick the ODD ONE OUT.", "Now, let's start again..." } };
/**
* The coin reward.
*/
private static final Item COINS = new Item(995, 1000);
/**
* The mystery box reward.
*/
private static final Item MYSTERY_BOX = new Item(6199);
/**
* The quiz master event.
*/
private QuizMasterEvent event;
/**
* The wrong button id.
*/
private int wrongId;
/**
* Constructs a new {@code QuizMasterDialogue} {@code Object}.
*/
public QuizMasterDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code QuizMasterDialogue} {@code Object}.
* @param player the player.
*/
public QuizMasterDialogue(final Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new QuizMasterDialogue(player);
}
@Override
public boolean open(Object... args) {
event = (QuizMasterEvent) args[0];
if (!event.isStartedQuiz()) {
event.setStartedQuiz(true);
} else {
if (event.getScore() == 4) {
npc(BLUE + "CONGRATULATIONS!", "You are a " + RED + "WINNER</col>!", "Please choose your " + BLUE + "PRIZE</col>!");
stage = 4;
return true;
}
npc(event.getScore() == 0 ? ("Okay! First question!") : "Okay! Next question!");
stage = 2;
return true;
}
npc("WELCOME to the GREATEST QUIZ SHOW in the", "whole of " + GameWorld.getSettings().getName() + ".", "<col=7f0000>O <col=6f000f>D <col=5f001f>D <col=4f002f>O <col=3f003f>N <col=2f004f>E <col=1f005f>O <col=0f006f>U <col=00007f>T");
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
interpreter.sendDialogues(player, FacialExpression.THINKING, "I'm sure I didn't ask to take part in a quiz show...");
stage++;
break;
case 1:
npc("Please welcome our newest contestant:", RED + player.getUsername(), "Just pick the ODD ONE OUT", "Four questions right, and then you win!");
stage++;
break;
case 2:
display(QuizSet.getQuizSet());
player.getInterfaceManager().openChatbox(191);
stage++;
break;
case 3:
buttonId -= 4;
final boolean wrong = wrongId != buttonId;
if (wrong) {
event.resetScore();
} else {
event.incrementScore();
}
if (event.getScore() == 4) {
npc(BLUE + "CONGRATULATIONS!", "You are a " + RED + "WINNER</col>!", "Please choose your " + BLUE + "PRIZE</col>!");
stage = 4;
break;
}
npc(getDialogue(wrong ? WRONG : CORRECT));
stage = 2;
break;
case 4:
options("1000 Coins", "Mystery Box");
stage++;
break;
case 5:
reward(buttonId == 1 ? COINS : MYSTERY_BOX);
break;
default:
System.out.println("UNHANDLED QUIZ STAGE " + stage + ", " + buttonId + ", " + interfaceId);
break;
}
return true;
}
/**
* Rewards the player.
* @param item the item.
*/
private void reward(Item item) {
end();
event.terminate();
Location destination = player.getAttribute("ame:location");
if (destination != null) {
if (!player.getInventory().hasSpaceFor(item)) {
GroundItemManager.create(item, destination, player);
} else {
player.getInventory().add(item);
}
player.getProperties().setTeleportLocation(destination);
}
}
/**
* Displays a quiz.
* @param quiz the quiz.
*/
private void display(QuizSet[] quiz) {
QuizSet correct = quiz[0];
QuizSet wrong = quiz[1];
List<Integer> childs = new ArrayList<>(20);
childs.add(1);
childs.add(2);
childs.add(3);
Collections.shuffle(childs);
for (int i = 0; i < 2; i++) {
sendItem(correct.getModel(i), childs.get(i));
}
wrongId = childs.get(2);
sendItem(wrong.getModel(RandomFunction.random(wrong.ids.length)), wrongId);
}
/**
* Sends an item.
* @param model the model.
* @param index the index.
*/
private void sendItem(int model, int index) {
PacketRepository.send(DisplayModel.class, new DisplayModelContext(player, ModelType.MODEL, model, 190, 191, 4 + index));
}
/**
* Gets the dialogues of a 2d array.
* @param dialogues the dialogues.
* @return the dialogues.
*/
public String[] getDialogue(String[][] dialogues) {
return dialogues[RandomFunction.random(dialogues.length)];
}
@Override
public int[] getIds() {
return new int[] { 2477 };
}
/**
* Fish, 6189, 6190, Weapons - 6191, 6192, Armour - 6193, 6194, Craftings -
* 6195, 6196, Jewllery - 6197, 6198
*/
/**
* Represents a quiz set.
* @author Vexia
*/
public enum QuizSet {
FISH(6189, 6190), WEAPONRY(6191, 6192), ARMOUR(6193, 6194), TOOLS(6195, 6196), JEWELLERY(6197, 6198);
/**
* The item ids.
*/
private int[] ids;
/**
* Constructs a new {@code QuizSet} {@code Object}.
* @param ids the ids.
*/
private QuizSet(int... ids) {
this.ids = ids;
}
/**
* Gets the quiz set.
* @return the set.
*/
public static QuizSet[] getQuizSet() {
List<QuizSet> sets = new ArrayList<>(20);
for (QuizSet s : values()) {
sets.add(s);
}
Collections.shuffle(sets);
QuizSet[] set = new QuizSet[2];
set[0] = sets.get(0);
sets.remove(set[0]);
set[1] = sets.get(RandomFunction.random(sets.size()));
return set;
}
/**
* Gets the model id.
* @param index the index.
* @return the model.
*/
public int getModel(int index) {
return ItemDefinition.forId(ids[index]).getInterfaceModelId();
}
}
}

View file

@ -1,203 +0,0 @@
package core.game.content.ame.events.quizmaster;
import java.nio.ByteBuffer;
import rs09.ServerConstants;
import core.game.content.ame.AntiMacroEvent;
import core.game.node.entity.Entity;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.SavedData;
import core.game.world.map.Location;
import core.net.packet.PacketRepository;
import core.net.packet.context.CameraContext;
import core.net.packet.context.CameraContext.CameraType;
import core.net.packet.out.CameraViewPacket;
import core.plugin.Initializable;
import rs09.plugin.PluginManager;
/**
* Handles the quiz master random event.
* @author Vexia
*/
@Initializable
public final class QuizMasterEvent extends AntiMacroEvent {
/**
* The quiz master random event.
*/
private NPC quizMaster;
/**
* The score of the quiz.
*/
private int score;
/**
* If the quiz was started.
*/
private boolean startedQuiz;
/**
* Constructs a new {@code QuizMasterEvent} {@code Object}.
*/
public QuizMasterEvent() {
super("quiz master", true, true);
}
@Override
public boolean enter(Entity entity) {
/*
* if (player.getName().equals("vexia")) { return false; } if (entity
* instanceof Player) { ((Player)
* entity).getInterfaceManager().removeTabs(0, 1, 2, 3, 4, 5, 6, 7, 11,
* 12); } return super.enter(entity);
*/
return false;
}
@Override
public boolean start(Player player, boolean login, Object... args) {
return false;
/*
* if (player.getName().equals("vexia")) { return false; }
*/
/*
* setRegion(); if (login) { quizMaster = NPC.create(2477,
* getLocation(32, 32)); quizMaster.init(); teleport(); if (startedQuiz)
* { startQuiz(); } return true; } player.getPulseManager().clear();
* player.getInterfaceManager().close(); setQuizMaster(false); if
* (quizMaster == null) { return false; }
* player.setAttribute("ame:location", player.getLocation());
* player.lock(5); quizMaster.lock(5); quizMaster.face(player);
* quizMaster.graphics(Graphics.create(86));
* quizMaster.sendChat("It's your lucky day!");
* player.graphics(Graphics.create(86), 3); GameWorld.getPulser().submit(new
* Pulse(4, player, quizMaster) {
* @Override public boolean pulse() { teleport(); setQuizMaster(true);
* return true; } }); super.init(player); return true;
*/
}
@Override
public boolean leave(Entity e, boolean logout) {
if (e == player) {
if (!logout) {
terminate();
} else {
if (quizMaster != null) {
quizMaster.clear();
}
region.flagInactive();
}
}
return super.leave(e, logout);
}
@Override
public void terminate() {
super.terminate();
quizMaster = null;
if (player != null) {
player.getAnimator().reset();
player.getAppearance().setDefaultAnimations();
player.getAppearance().sync();
player.getInterfaceManager().restoreTabs();
PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraType.RESET, 0, 0, 0, 0, 0));
}
}
@Override
public AntiMacroEvent create(Player player) {
final QuizMasterEvent event = new QuizMasterEvent();
event.player = player;
return event;
}
/**
* Resets the score.
*/
public void resetScore() {
score = 0;
}
/**
* Increments the score.
*/
public void incrementScore() {
score++;
}
/**
* Gets the score.
* @return the score.
*/
public int getScore() {
return score;
}
/**
* Sets the region.
*/
/*
* private void setRegion() { region = DynamicRegion.create(7754);
* registerRegion(region.getId()); } /** Teleports the player to the quiz.
*/
/*
* private void teleport() {
* player.getAppearance().setAnimations(Animation.create(2378));
* player.getAppearance().sync(); player.faceLocation(getLocation(32, 32));
* player.getProperties().setTeleportLocation(getLocation(32, 28));
* startQuiz(); } /** Sets the quiz master.
*/
/*
* private void setQuizMaster(boolean teleport) { if (quizMaster == null) {
* quizMaster = new QuizMasterNPC(2477, player.getLocation(), this, player);
* quizMaster.init(); } if (teleport) {
* quizMaster.getProperties().setTeleportLocation(getLocation(32, 32)); } }
* /** Stars the quiz.
*/
/*
* private void startQuiz() { player.getDialogueInterpreter().open(2477,
* this); player.sendMessage(
* "Answer four questions correctly in a row to be teleported back where you came from."
* ); } /** Gets the startedQuiz.
* @return The startedQuiz.
*/
public boolean isStartedQuiz() {
return startedQuiz;
}
/**
* Sets the startedQuiz.
* @param startedQuiz The startedQuiz to set.
*/
public void setStartedQuiz(boolean startedQuiz) {
this.startedQuiz = startedQuiz;
}
/**
* Gets the transformed location.
* @return the location.
*/
/*
* private Location getLocation(int xOff, int yOff) { return
* region.getBaseLocation().transform(xOff, yOff, 1); }
*/
@Override
public void register() {
PluginManager.definePlugin(new QuizMasterDialogue());
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
}

View file

@ -1,53 +0,0 @@
package core.game.content.ame.events.quizmaster;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.ame.AntiMacroNPC;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
import rs09.game.world.repository.Repository;
/**
* Handles the quiz master npc.
* @author Vexia
*/
public final class QuizMasterNPC extends AntiMacroNPC {
/**
* Constructs a new {@code QuizMasterNPC} {@code Object}.
* @param id the id.
* @param location the location.
* @param event the event.
* @param player the player.
*/
public QuizMasterNPC(int id, Location location, AntiMacroEvent event, Player player) {
super(id, location, event, player);
}
@Override
public void handleTickActions() {
if (!getLocks().isMovementLocked()) {
if (dialoguePlayer == null || !dialoguePlayer.isActive() || !dialoguePlayer.getInterfaceManager().hasChatbox()) {
dialoguePlayer = null;
}
}
if (!player.isActive()) {
clear();
}
if (!getPulseManager().hasPulseRunning()) {
startFollowing();
}
}
@Override
public void clear() {
Repository.removeRenderableNPC(this);
Repository.getNpcs().remove(this);
getViewport().setCurrentPlane(null);
}
@Override
public int[] getIds() {
return new int[] { 2477 };
}
}

View file

@ -1,142 +0,0 @@
package core.game.content.ame.events.rickturpentine;
import java.nio.ByteBuffer;
import core.game.content.ame.AntiMacroDialogue;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.dialogue.DialoguePlugin;
import core.game.node.entity.npc.drop.DropFrequency;
import core.game.node.entity.player.Player;
import core.game.node.item.ChanceItem;
import core.game.node.item.Item;
import core.game.world.map.Location;
import rs09.plugin.PluginManager;
import core.plugin.Initializable;
import core.tools.RandomFunction;
import org.rs09.consts.Items;
/**
* Handles the rick turpentine anti macro event.
* @author Vexia
*/
@Initializable
public final class RickTurpentineEvent extends AntiMacroEvent {
/**
* The name of the event.
*/
public static final String NAME = "rick turpentine";
/**
* Constructs a new {@code RickTurpentineEvent} {@code Object}.
*/
public RickTurpentineEvent() {
super(NAME, true, false);
}
@Override
public boolean start(Player player, boolean login, Object... args) {
final RickTurpentineNPC npc = new RickTurpentineNPC(2476, player.getLocation(), this, player);
npc.init();
super.init(player);
return true;
}
@Override
public AntiMacroEvent create(Player player) {
RickTurpentineEvent event = new RickTurpentineEvent();
event.player = player;
return event;
}
@Override
public void register() {
PluginManager.definePlugin(new RickTurpentineDialogue());
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
@Override
public String getGenderPrefix(boolean male) {
return male ? "milord" : "milady";
}
/**
* Handles the rick turpnetine dialogue.
* @author Vexia
*/
public static final class RickTurpentineDialogue extends AntiMacroDialogue {
/**
* The random items recieved from rick turpnetine.
*/
private static final ChanceItem[] ITEMS = new ChanceItem[] {
new ChanceItem(Items.COINS_995, 1, 640, DropFrequency.COMMON),
new ChanceItem(Items.SPINACH_ROLL_1969, 1, 1, DropFrequency.COMMON),
new ChanceItem(Items.KEBAB_1971, 1, 1, DropFrequency.COMMON),
new ChanceItem(Items.UNCUT_SAPPHIRE_1623, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.UNCUT_EMERALD_1621, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.UNCUT_RUBY_1619, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.UNCUT_DIAMOND_1617, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.COSMIC_TALISMAN_1454, 1, 1, DropFrequency.UNCOMMON),
new ChanceItem(Items.TOOTH_HALF_OF_A_KEY_985, 1, 1, DropFrequency.RARE)};
/**
* Constructs a new {@code RickTurpentineDialogue} {@code Object}.
*/
public RickTurpentineDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code RickTurpentineDialogue} {@code Object}.
* @param player the player.
*/
public RickTurpentineDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new RickTurpentineDialogue(player);
}
@Override
public boolean open(Object... args) {
if (super.open(args)) {
npc("Today is your lucky day, sirrah!", "I am donating to the victims of crime to atone for my", "past actions!");
} else {
return true;
}
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
Item item = RandomFunction.getChanceItem(ITEMS).getRandomItem();
if (item.getId() == Items.TOOTH_HALF_OF_A_KEY_985 && RandomFunction.randomSign(1) <= 0) {
item = new Item(Items.LOOP_HALF_OF_A_KEY_987);
}
player.getInventory().add(item, player);
wave(null);
return true;
}
@Override
public int[] getIds() {
return new int[] { 2476 };
}
}
}

View file

@ -1,74 +0,0 @@
package core.game.content.ame.events.rickturpentine;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.ame.AntiMacroNPC;
import core.game.node.entity.Entity;
import core.game.node.entity.player.Player;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.map.Location;
/**
* Handles the drunken dwarf npc.
* @author Vexia
*/
public final class RickTurpentineNPC extends AntiMacroNPC {
/**
* The quotes that the dwarf will say.
*/
private static final String[] QUOTES = new String[] { "Greetings, @gender @name!", "Your money or your life, @name!" };
/**
* Constructs a new {@code RickTurpentineNPC} {@code Object}.
* @param id the id.
* @param location the loc.
* @param event the event.
* @param player the player.
*/
public RickTurpentineNPC(int id, Location location, AntiMacroEvent event, Player player) {
super(id, location, event, player, QUOTES);
}
@Override
public void handleTickActions() {
super.handleTickActions();
if (timeUp && getDialoguePlayer() == null) {
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(player);
}
}
}
@Override
public void handlePlayerLeave() {
sendChat("What a dismal little spot this is");
GameWorld.getPulser().submit(new Pulse(3) {
@Override
public boolean pulse() {
clear();
return true;
}
});
}
@Override
public void handleTimeUp() {
}
@Override
public boolean isIgnoreAttackRestrictions(Entity victim) {
return true;
}
@Override
public boolean isIgnoreMultiBoundaries(Entity victim) {
return victim == player;
}
@Override
public int[] getIds() {
return new int[] { 2476 };
}
}

View file

@ -1,71 +0,0 @@
package core.game.content.ame.events.rivertroll;
import java.nio.ByteBuffer;
import core.game.content.ame.AntiMacroEvent;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.player.Player;
import core.plugin.Initializable;
import core.game.world.map.Location;
/**
* Handles the zombie event.
* @author Vexia
*/
@Initializable
public final class RiverTrollEvent extends AntiMacroEvent {
/**
* Constructs a new {@code ZombieEvent} {@code Object}.
*/
public RiverTrollEvent() {
super("river troll", true, false, Skills.FISHING);
}
@Override
public boolean start(Player player, boolean login, Object... args) {
final RiverTrollNPC troll = new RiverTrollNPC(getId(player), player.getLocation(), this, player);
troll.init();
super.init(player);
return true;
}
@Override
public AntiMacroEvent create(Player player) {
RiverTrollEvent event = new RiverTrollEvent();
event.player = player;
return event;
}
/**
* Gets the id of the shade.
* @param player the player.
* @return the id.
*/
private int getId(Player player) {
int level = player.getProperties().getCurrentCombatLevel();
int npcId = 396;
if (level < 11) {
npcId = 391;
} else if (level < 21) {
npcId = 392;
} else if (level < 41) {
npcId = 393;
} else if (level < 61) {
npcId = 394;
} else if (level < 91) {
npcId = 395;
}
return npcId;
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
}

View file

@ -1,70 +0,0 @@
package core.game.content.ame.events.rivertroll;
import core.cache.def.impl.NPCDefinition;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.ame.AntiMacroNPC;
import core.game.node.entity.Entity;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
import core.game.world.update.flag.context.Animation;
import core.tools.RandomFunction;
/**
* Handles the river troll npc.
* @author Vexia
*/
public final class RiverTrollNPC extends AntiMacroNPC {
/**
* The river troll npc.
*/
private static final int[] IDS = new int[] { 391, 392, 393, 394, 395, 396 };
/**
* Constructs a new {@code RiverTrollNPC} {@code Object}.
* @param id the id.
* @param location the location.
* @param event the event.
* @param player the player.
*/
public RiverTrollNPC(int id, Location location, AntiMacroEvent event, Player player) {
super(id, location, event, player);
}
@Override
public void init() {
// Remove.
NPCDefinition def = NPCDefinition.forId(getId());
def.getHandlers().put("attack_animation", new Animation(284));
def.getHandlers().put("defence_animation", new Animation(285));
def.getHandlers().put("death_animation", new Animation(287));
super.init();
setRespawn(false);
getProperties().getCombatPulse().attack(player);
sendChat("Fishies be mine! Leave dem fishies!");
}
@Override
public void handleTickActions() {
super.handleTickActions();
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(player);
}
if (getProperties().getCombatPulse().isAttacking()) {
if (RandomFunction.random(20) < 3) {
sendChat("Fishies be mine! Leave dem fishies!");
}
}
}
@Override
public boolean isIgnoreMultiBoundaries(Entity victim) {
return victim == player;
}
@Override
public int[] getIds() {
return IDS;
}
}

View file

@ -1,71 +0,0 @@
package core.game.content.ame.events.shade;
import java.nio.ByteBuffer;
import core.game.content.ame.AntiMacroEvent;
import core.plugin.Initializable;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
/**
* Handles the shade event.
* @author Vexia
*/
@Initializable
public final class ShadeEvent extends AntiMacroEvent {
/**
* Constructs a new {@code ShadeEvent} {@code Object}.
*/
public ShadeEvent() {
super("shade", true, false, Skills.PRAYER);
}
@Override
public boolean start(Player player, boolean login, Object... args) {
final ShadeNPC shade = new ShadeNPC(getId(player), player.getLocation(), this, player);
shade.init();
super.init(player);
return true;
}
@Override
public AntiMacroEvent create(Player player) {
ShadeEvent event = new ShadeEvent();
event.player = player;
return event;
}
/**
* Gets the id of the shade.
* @param player the player.
* @return the id.
*/
private int getId(Player player) {
int level = player.getProperties().getCurrentCombatLevel();
int npcId = 430;
if (level < 11) {
npcId = 425;
} else if (level < 21) {
npcId = 426;
} else if (level < 41) {
npcId = 427;
} else if (level < 61) {
npcId = 428;
} else if (level < 91) {
npcId = 429;
}
return npcId;
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
}

View file

@ -1,56 +0,0 @@
package core.game.content.ame.events.shade;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.ame.AntiMacroNPC;
import core.game.node.entity.Entity;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
/**
* Handles the shade npc.
* @author Vexia
*/
public final class ShadeNPC extends AntiMacroNPC {
/**
* The shade npc ids.
*/
private static final int[] IDS = new int[] { 425, 426, 427, 428, 429, 430 };
/**
* Constructs a new {@code ShadeNPC} {@code Object}.
* @param id the id.
* @param location the location.
* @param event the event.
* @param player the player.
*/
public ShadeNPC(int id, Location location, AntiMacroEvent event, Player player) {
super(id, location, event, player);
}
@Override
public void init() {
super.init();
setRespawn(false);
getProperties().getCombatPulse().attack(player);
}
@Override
public void handleTickActions() {
super.handleTickActions();
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(player);
}
}
@Override
public boolean isIgnoreMultiBoundaries(Entity victim) {
return victim == player;
}
@Override
public int[] getIds() {
return IDS;
}
}

View file

@ -1,71 +0,0 @@
package core.game.content.ame.events.treespirit;
import java.nio.ByteBuffer;
import core.game.content.ame.AntiMacroEvent;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.player.Player;
import core.plugin.Initializable;
import core.game.world.map.Location;
/**
* Handles the Tree Spirit event whilst cutting trees.
* @author Splinter
*/
@Initializable
public final class TreeSpiritEvent extends AntiMacroEvent {
/**
* Constructs a new {@code TreeSpiritEvent} {@code Object}.
*/
public TreeSpiritEvent() {
super("tree spirit", true, false, Skills.WOODCUTTING);
}
@Override
public boolean start(Player player, boolean login, Object... args) {
final TreeSpiritRandomNPC spirit = new TreeSpiritRandomNPC(getId(player), player.getLocation(), this, player);
spirit.init();
super.init(player);
return true;
}
@Override
public AntiMacroEvent create(Player player) {
TreeSpiritEvent event = new TreeSpiritEvent();
event.player = player;
return event;
}
/**
* Gets the id of the spirit.
* @param player the player.
* @return the id.
*/
private int getId(Player player) {
int level = player.getProperties().getCurrentCombatLevel();
int npcId = 443;
if (level < 11) {
npcId = 438;
} else if (level < 21) {
npcId = 439;
} else if (level < 41) {
npcId = 440;
} else if (level < 61) {
npcId = 441;
} else if (level < 91) {
npcId = 442;
}
return npcId;
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
}

View file

@ -1,69 +0,0 @@
package core.game.content.ame.events.treespirit;
import core.cache.def.impl.NPCDefinition;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.ame.AntiMacroNPC;
import core.game.node.entity.Entity;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
import core.game.world.update.flag.context.Animation;
import core.tools.RandomFunction;
/**
* Handles the Tree Spirit NPCs
* @author Splinter
*/
public final class TreeSpiritRandomNPC extends AntiMacroNPC {
/**
* The tree spirit npc ids.
*/
private static final int[] IDS = new int[] { 438, 439, 440, 441, 442, 443 };
/**
* Constructs a new {@code TreeSpiritRandomNPC} {@code Object}.
* @param id the id.
* @param location the location.
* @param event the event.
* @param player the player.
*/
public TreeSpiritRandomNPC(int id, Location location, AntiMacroEvent event, Player player) {
super(id, location, event, player);
}
@Override
public void init() {
NPCDefinition def = NPCDefinition.forId(getId());
def.getHandlers().put("attack_animation", new Animation(94));
def.getHandlers().put("defence_animation", new Animation(95));
def.getHandlers().put("death_animation", new Animation(96));
super.init();
setRespawn(false);
getProperties().getCombatPulse().attack(player);
sendChat("Leave these woods and never return!");
}
@Override
public void handleTickActions() {
super.handleTickActions();
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(player);
}
if (getProperties().getCombatPulse().isAttacking()) {
if (RandomFunction.random(40) < 2) {
sendChat("Leave these woods and never return!");
}
}
}
@Override
public boolean isIgnoreMultiBoundaries(Entity victim) {
return victim == player;
}
@Override
public int[] getIds() {
return IDS;
}
}

View file

@ -1,63 +0,0 @@
package core.game.content.ame.events.zombie;
import core.game.content.ame.AntiMacroEvent;
import core.game.content.ame.AntiMacroNPC;
import core.game.node.entity.Entity;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
import core.tools.RandomFunction;
/**
* Handles the zombie npc.
* @author Vexia
*/
public final class ZombieAmeNPC extends AntiMacroNPC {
/**
* The zombie npc.
*/
private static final int[] IDS = new int[] { 419, 420, 421, 422, 423, 424 };
/**
* Constructs a new {@code ZombieNPC} {@code Object}.
* @param id the id.
* @param location the location.
* @param event the event.
* @param player the player.
*/
public ZombieAmeNPC(int id, Location location, AntiMacroEvent event, Player player) {
super(id, location, event, player);
}
@Override
public void init() {
super.init();
setRespawn(false);
getProperties().getCombatPulse().attack(player);
sendChat("Braaiinnzzzzzzzzzz");
}
@Override
public void handleTickActions() {
super.handleTickActions();
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(player);
}
if (getProperties().getCombatPulse().isAttacking()) {
if (RandomFunction.random(20) < 3) {
sendChat("Braaiinnzzzzzzzzzz");
}
}
}
@Override
public boolean isIgnoreMultiBoundaries(Entity victim) {
return victim == player;
}
@Override
public int[] getIds() {
return IDS;
}
}

View file

@ -1,71 +0,0 @@
package core.game.content.ame.events.zombie;
import java.nio.ByteBuffer;
import core.game.content.ame.AntiMacroEvent;
import core.plugin.Initializable;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
/**
* Handles the zombie event.
* @author Vexia
*/
@Initializable
public final class ZombieEvent extends AntiMacroEvent {
/**
* Constructs a new {@code ZombieEvent} {@code Object}.
*/
public ZombieEvent() {
super("zombie", true, false, Skills.PRAYER);
}
@Override
public boolean start(Player player, boolean login, Object... args) {
final ZombieAmeNPC zombie = new ZombieAmeNPC(getId(player), player.getLocation(), this, player);
zombie.init();
super.init(player);
return true;
}
@Override
public AntiMacroEvent create(Player player) {
ZombieEvent event = new ZombieEvent();
event.player = player;
return event;
}
/**
* Gets the id of the shade.
* @param player the player.
* @return the id.
*/
private int getId(Player player) {
int level = player.getProperties().getCurrentCombatLevel();
int npcId = 424;
if (level < 11) {
npcId = 419;
} else if (level < 21) {
npcId = 420;
} else if (level < 41) {
npcId = 421;
} else if (level < 61) {
npcId = 422;
} else if (level < 91) {
npcId = 423;
}
return npcId;
}
@Override
public Location getSpawnLocation() {
return null;
}
@Override
public void configure() {
}
}

View file

@ -6,6 +6,8 @@ import core.game.world.map.zone.ZoneBorders;
import core.plugin.Initializable;
import core.game.node.entity.player.Player;
import static rs09.tools.DialogueConstKt.END_DIALOGUE;
/**
* Represents the dialogue plugin used for the hans npc.
@ -112,15 +114,9 @@ public final class HansDialoguePlugin extends DialoguePlugin {
}
break;
case 4:
if(player.getAntiMacroHandler().isDisabled){
interpreter.sendOptions("Select an Option","I want to enable random events.","Nevermind.");
stage = 130;
interpreter.sendDialogue("Randoms are now permanently enabled. This option to be removed","at a later date.");
stage = END_DIALOGUE;
break;
} else {
interpreter.sendOptions("Select an Option","I want to disable random events.","Nevermind.");
stage = 135;
break;
}
case 5: // Go back
interpreter.sendOptions("Select an Option", "I'm looking for whoever is in charge of this place.", "I have come to kill everyone in this castle!", "I don't know. I'm lost. Where am I?", "More Options...");
stage = 1;
@ -322,38 +318,9 @@ public final class HansDialoguePlugin extends DialoguePlugin {
}
break;
case 130:
switch(buttonId){
case 1:
npc("Voila, you should now get random events!");
player.getAntiMacroHandler().isDisabled = false;
player.setAttribute("/save:randoms:disabled",false);
player.getAntiMacroHandler().init();
stage = 131;
break;
case 2:
player("Never mind.");
stage = 131;
break;
}
break;
case 131:
end();
break;
case 135:
switch(buttonId){
case 1:
npc("Voila, you shouldn't get random events now!");
player.getAntiMacroHandler().isDisabled = true;
player.setAttribute("/save:randoms:disabled",true);
stage = 131;
break;
case 2:
player("Never mind.");
stage = 131;
break;
}
break;
//Change Iron man mode dialogue/code
case 150:
switch(buttonId){

View file

@ -6,7 +6,6 @@ import core.game.container.impl.BankContainer;
import core.game.container.impl.EquipmentContainer;
import core.game.container.impl.InventoryListener;
import core.game.content.activity.pyramidplunder.PlunderObjectManager;
import core.game.content.ame.AntiMacroHandler;
import core.game.content.dialogue.DialogueInterpreter;
import core.game.content.quest.miniquest.barcrawl.BarcrawlManager;
import core.game.content.ttrail.TreasureTrailManager;
@ -73,6 +72,7 @@ import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import rs09.ServerConstants;
import rs09.game.VarpManager;
import rs09.game.content.ame.RandomEventManager;
import rs09.game.ge.PlayerGrandExchange;
import rs09.game.node.entity.combat.CombatSwingHandler;
import rs09.game.node.entity.combat.equipment.EquipmentDegrader;
@ -277,7 +277,7 @@ public class Player extends Entity {
/**
* The anti macro handler.
*/
private final AntiMacroHandler antiMacroHandler = new AntiMacroHandler(this);
private final RandomEventManager antiMacroHandler = new RandomEventManager(this);
/**
* The hunter manager.
@ -365,7 +365,6 @@ public class Player extends Entity {
@Override
public void init() {
antiMacroHandler.isDisabled = getAttribute("randoms:disabled",false);
if (!artificial) {
getProperties().setSpawnLocation(ServerConstants.HOME_LOCATION);
getDetails().getSession().setObject(this);
@ -467,7 +466,7 @@ public class Player extends Entity {
@Override
public void tick() {
super.tick();
antiMacroHandler.pulse();
antiMacroHandler.tick();
hunterManager.pulse();
musicPlayer.tick();
if(getAttribute("fire:immune",0) > 0){
@ -1199,7 +1198,7 @@ public class Player extends Entity {
* Gets the antiMacroHandler.
* @return The antiMacroHandler.
*/
public AntiMacroHandler getAntiMacroHandler() {
public RandomEventManager getAntiMacroHandler() {
return antiMacroHandler;
}

View file

@ -1,6 +1,5 @@
package core.game.node.entity.skill;
import core.game.content.ame.ExperienceMonitor;
import core.game.content.quest.tutorials.tutorialisland.TutorialSession;
import core.game.interaction.item.brawling_gloves.BrawlingGloves;
import core.game.node.entity.Entity;
@ -238,12 +237,6 @@ public final class Skills {
}
}
this.experience[slot] += experienceAdd;
try {
player.getAntiMacroHandler().monitors[slot].setExperienceAmount((int) experienceAdd);
} catch (Exception e){
player.getAntiMacroHandler().monitors[slot] = new ExperienceMonitor(slot);
player.getAntiMacroHandler().monitors[slot].setExperienceAmount((int) experienceAdd);
}
if (this.experience[slot] >= 200000000) {
if(!already200m && !player.isArtificial()){
Repository.sendNews(entity.asPlayer().getUsername()+" has just reached 200m experience in " + SKILL_NAME[slot] + "!");

View file

@ -7,21 +7,20 @@ import core.game.content.global.BirdNest;
import core.game.content.global.SkillingPets;
import core.game.content.quest.tutorials.tutorialisland.TutorialSession;
import core.game.content.quest.tutorials.tutorialisland.TutorialStage;
import core.game.node.entity.skill.SkillPulse;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.impl.Projectile;
import core.game.node.entity.player.Player;
import core.game.node.entity.skill.SkillPulse;
import core.game.node.entity.skill.Skills;
import core.game.node.item.Item;
import core.game.node.object.GameObject;
import core.game.node.object.ObjectBuilder;
import rs09.game.world.GameWorld;
import core.game.world.map.Location;
import core.tools.RandomFunction;
import core.tools.StringUtils;
import rs09.game.world.GameWorld;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* Handles a gathering skill, such as woodcutting, mining, ...
@ -138,11 +137,6 @@ public final class GatheringSkillPulse extends SkillPulse<GameObject> {
} else if (tutorialStage == 37 && node.getId() == 3042) {
TutorialStage.load(player, 39, false);
}
// If player is in donator zone
if (isWoodcutting && player.getLocation().getRegionId() == 12102) {
player.getAntiMacroHandler().fireEvent("tree spirit");
return true;
}
// 20% chance to auto burn logs when using "inferno adze" item
if (isWoodcutting && tool.getId() == 13661 && RandomFunction.random(100) < 20){
player.sendMessage("Your chop some logs. The heat of the inferno adze incinerates them.");

View file

@ -124,11 +124,11 @@ public class WoodcuttingSkillPulse extends Pulse {
// If player is in donator zone
if (player.getLocation().getRegionId() == 12102) {
/* if (player.getLocation().getRegionId() == 12102) {
player.getAntiMacroHandler().fireEvent("tree spirit");
return true;
}
*/
// 20% chance to auto burn logs when using "inferno adze" item
if (SkillingTool.getHatchet(player).getId() == 13661 && RandomFunction.random(100) < 25) {
player.sendMessage("You chop some logs. The heat of the inferno adze incinerates them.");

View file

@ -2,7 +2,6 @@ package core.game.world.map.zone.impl;
import core.game.component.Component;
import core.game.container.Container;
import core.game.content.ame.AntiMacroNPC;
import core.game.content.ttrail.UriNPC;
import core.game.interaction.Option;
import core.game.interaction.item.brawling_gloves.BrawlingGloves;
@ -196,7 +195,7 @@ public final class WildernessZone extends MapZone {
}
if (e instanceof NPC || e instanceof AntiMacroNPC) {
if (e instanceof NPC) {
e.asNpc().setRespawnTick(GameWorld.getTicks() + e.asNpc().getDefinition().getConfiguration(NPCConfigParser.RESPAWN_DELAY, 17));
if (!e.asNpc().isRespawn()) {
e.asNpc().clear();
@ -238,7 +237,6 @@ public final class WildernessZone extends MapZone {
p.getSkullManager().setWilderness(true);
p.getSkullManager().setLevel(getWilderness(p));
}
p.getAntiMacroHandler().isDisabled = true;
for (int i = 0; i < 7; i++) {
if (i == 5 || i == 3) {
continue;
@ -270,7 +268,6 @@ public final class WildernessZone extends MapZone {
if (!logout && e instanceof Player) {
Player p = (Player) e;
leave(p);
p.getAntiMacroHandler().isDisabled = p.getAttribute("randoms:disabled",false);
if (p.getFamiliarManager().hasFamiliar() && !p.getFamiliarManager().hasPet()) {
Familiar familiar = p.getFamiliarManager().getFamiliar();
if (familiar.isCombatFamiliar()) {

View file

@ -0,0 +1,30 @@
package rs09.game.content.ame
import core.game.node.entity.player.Player
import rs09.game.system.SystemLogger
import rs09.game.world.GameWorld
private const val DELAY_TICKS = 6000 //60 minutes
class RandomEventManager(val player: Player) {
var event: RandomEventNPC? = null
var nextSpawn = 0
fun tick(){
if(player.isArtificial) return
if(GameWorld.ticks > nextSpawn) fireEvent()
}
fun fireEvent(){
val ame = RandomEvents.values().random()
event = ame.npc.create(player,ame.loot)
event!!.init()
nextSpawn = GameWorld.ticks + DELAY_TICKS
SystemLogger.logRE("Fired ${event!!.name} for ${player.username}")
}
fun init(){
if(player.isArtificial) return
nextSpawn = GameWorld.ticks + DELAY_TICKS
SystemLogger.logRE("Initialized REManager for ${player.username}")
}
}

View file

@ -18,11 +18,11 @@ class CerterDialogue(val initial: Boolean) : DialogueFile() {
} else {
val isCorrect = player!!.getAttribute("certer:correct",false)
when(stage){
0 -> if(!isCorrect) npc("Sorry, I don't think so.").also { stage = END_DIALOGUE; player!!.antiMacroHandler.event.terminate() } else npc("Oh yes! That's right.").also { stage++ }
0 -> if(!isCorrect) npc("Sorry, I don't think so.").also { stage = END_DIALOGUE; player!!.antiMacroHandler.event?.terminate() } else npc("Oh yes! That's right.").also { stage++ }
1 -> {
npc("Please, take this as a thanks.")
player!!.antiMacroHandler.event.loot!!.roll(player!!).forEach { player!!.inventory.add(it) }
player!!.antiMacroHandler.event.terminate()
player!!.antiMacroHandler.event?.loot!!.roll(player!!).forEach { player!!.inventory.add(it) }
player!!.antiMacroHandler.event?.terminate()
stage = END_DIALOGUE
}
}

View file

@ -25,7 +25,7 @@ class CerterEventInterface : InterfaceListener() {
val correctAnswer = player.getAttribute("certer:correctIndex",0)
player.setAttribute("certer:correct",correctAnswer == answer)
player.interfaceManager.close()
player.dialogueInterpreter.open(CerterDialogue(false),player.antiMacroHandler.event.asNpc())
player.dialogueInterpreter.open(CerterDialogue(false),player.antiMacroHandler.event?.asNpc())
return@on true
}

View file

@ -39,11 +39,11 @@ class SeargentDamienDialogue(val isCorrect: Boolean = false) : DialogueFile() {
1 -> {
end()
DrillDemonUtils.teleport(player!!)
player!!.antiMacroHandler.event.terminate()
player!!.antiMacroHandler.event?.terminate()
stage = END_DIALOGUE
}
2 -> {
player!!.antiMacroHandler.event.terminate()
player!!.antiMacroHandler.event?.terminate()
stage = END_DIALOGUE
}
}

View file

@ -26,13 +26,13 @@ class SandwichLadyDialogue(val isChoice: Boolean) : DialogueFile() {
0 -> if(choice != assigned){
npc!!.sendChat("That's not what I said you could have!")
player!!.impactHandler.manualHit(npc,3,ImpactHandler.HitsplatType.NORMAL)
player!!.antiMacroHandler.event.terminate()
player!!.antiMacroHandler.event?.terminate()
} else {
npc("Here you are, dear. I hope you enjoy it!")
if(!player!!.inventory.add(Item(assigned))){
GroundItemManager.create(Item(assigned),player)
}
player!!.antiMacroHandler.event.terminate()
player!!.antiMacroHandler.event?.terminate()
stage = END_DIALOGUE
}
}

View file

@ -16,10 +16,10 @@ class NPCTalkListener : InteractionListener() {
on(NPC,"talk-to","talk"){player,node ->
val npc = node.asNpc()
if(RandomEvents.randomIDs.contains(node.id)){
if(player.antiMacroHandler.event == null || player.antiMacroHandler.event.id != node.id){
if(player.antiMacroHandler.event == null || player.antiMacroHandler.event!!.id != node.id){
player.sendMessage("They aren't interested in talking to you.")
} else {
player.antiMacroHandler.event.talkTo(node.asNpc())
player.antiMacroHandler.event!!.talkTo(node.asNpc())
}
return@on true
}

View file

@ -1,6 +1,5 @@
package rs09.game.node.entity.player.info.login
import core.game.content.ame.AntiMacroHandler
import core.game.interaction.item.brawling_gloves.BrawlingGloves
import core.game.node.entity.combat.CombatSpell
import core.game.node.entity.player.Player
@ -186,11 +185,6 @@ class PlayerSaveParser(val player: Player) {
}
fun parseAntiMacro() {
if (saveFile!!.containsKey("antiMacroEvent")) {
val event: JSONObject = saveFile!!["antiMacroEvent"] as JSONObject
val ame = AntiMacroHandler.EVENTS.get(event.get("eventName") as String)
ame?.create(player)
}
}
fun parseStates() {

View file

@ -64,6 +64,11 @@ object SystemLogger {
if(message.isNotBlank()) t.println("${getTime()}: ${TextColors.gray("[AIPL] $message")}")
}
@JvmStatic
fun logRE(message: String){
if(message.isNotBlank()) t.println("${getTime()}: ${TextColors.gray("[RAND] $message")}")
}
@JvmStatic
fun logTrade(message: String){
if(message.isNotBlank()){

View file

@ -96,7 +96,7 @@ class RottenPotatoExtraDialogue(player: Player? = null) : DialoguePlugin(player)
return true
}
other?.antiMacroHandler?.fireEvent(AMEs[buttonId - 1])
//other?.antiMacroHandler?.fireEvent(AMEs[buttonId - 1])
return true
}

View file

@ -458,7 +458,7 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
define("testlady",Command.Privilege.ADMIN){player,_ ->
player.antiMacroHandler.event = RandomEvents.DRILL_DEMON.npc.create(player,null)
player.antiMacroHandler.event.init()
player.antiMacroHandler.event!!.init()
}
}
}