diff --git a/2006Scape Client/src/main/java/Class56.java b/2006Scape Client/src/main/java/Class56.java index 95d112a9..10d206bb 100644 --- a/2006Scape Client/src/main/java/Class56.java +++ b/2006Scape Client/src/main/java/Class56.java @@ -15,4 +15,7 @@ abstract class Class56 { abstract void method832(int i); abstract void method833(); + + void setLoop(boolean loop, boolean restartIfStopped) { + } } diff --git a/2006Scape Client/src/main/java/Class56_Sub1_Sub1.java b/2006Scape Client/src/main/java/Class56_Sub1_Sub1.java index 88cbb368..316d9201 100644 --- a/2006Scape Client/src/main/java/Class56_Sub1_Sub1.java +++ b/2006Scape Client/src/main/java/Class56_Sub1_Sub1.java @@ -1,7 +1,6 @@ -/* Class56_Sub1_Sub1 - Decompiled by JODE - * Visit http://jode.sourceforge.net/ - */ import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MidiMessage; @@ -10,90 +9,211 @@ import javax.sound.midi.Receiver; import javax.sound.midi.Sequence; import javax.sound.midi.Sequencer; import javax.sound.midi.ShortMessage; +import javax.sound.midi.Soundbank; +import javax.sound.midi.Synthesizer; final class Class56_Sub1_Sub1 extends Class56_Sub1 implements Receiver { + private static final Object MIDI_LOCK = new Object(); + private static final Object RECEIVER_LOCK = new Object(); private static Receiver aReceiver1850 = null; private static Sequencer aSequencer1851 = null; - + private static Synthesizer aSynthesizer = null; + final void method827(int i, byte[] is, int i_0_, boolean bool) { - if (aSequencer1851 != null) { - try { - Sequence sequence = MidiSystem.getSequence(new ByteArrayInputStream(is)); - aSequencer1851.setSequence(sequence); - aSequencer1851.setLoopCount(!bool ? 0 : -1); - method835(0, i, -1L); - aSequencer1851.start(); - } catch (Exception exception) { - /* empty */ - } - } + synchronized (MIDI_LOCK) { + if (aSequencer1851 != null && aSequencer1851.isOpen() && is != null && is.length > 0) { + try { + if (aSequencer1851.isRunning()) { + aSequencer1851.stop(); + } + method838(-1L); + Sequence sequence = MidiSystem.getSequence(new ByteArrayInputStream(is)); + aSequencer1851.setSequence(sequence); + aSequencer1851.setTickPosition(0); + aSequencer1851.setLoopCount(!bool ? 0 : Sequencer.LOOP_CONTINUOUSLY); + method840(i, -1L); + aSequencer1851.start(); + } catch (Exception exception) { + System.err.println("MIDI playback error: " + exception.getMessage()); + } + } + } } - + final void method833() { - if (aSequencer1851 != null) { - aSequencer1851.stop(); - method838(-1L); - } + synchronized (MIDI_LOCK) { + if (aSequencer1851 != null && aSequencer1851.isOpen()) { + try { + if (aSequencer1851.isRunning()) { + aSequencer1851.stop(); + } + method838(-1L); + } catch (Exception ignored) { + } + } + } } - - public final synchronized void send(MidiMessage midimessage, long l) { - byte[] is = midimessage.getMessage(); - if (is.length < 3 || !method837(is[0], is[1], is[2], l)) - aReceiver1850.send(midimessage, l); + + @Override + final void setLoop(boolean loop, boolean restartIfStopped) { + synchronized (MIDI_LOCK) { + if (aSequencer1851 != null && aSequencer1851.isOpen()) { + aSequencer1851.setLoopCount(loop ? Sequencer.LOOP_CONTINUOUSLY : 0); + if (restartIfStopped && !aSequencer1851.isRunning() && aSequencer1851.getSequence() != null) { + aSequencer1851.setTickPosition(0); + aSequencer1851.start(); + } + } + } } - + + public final void send(MidiMessage midimessage, long l) { + synchronized (RECEIVER_LOCK) { + if (aReceiver1850 == null || midimessage == null) { + return; + } + byte[] is = midimessage.getMessage(); + if (is.length < 3 || !method837(is[0], is[1], is[2], l)) { + aReceiver1850.send(midimessage, l); + } + } + } + + private static Soundbank loadCustomSoundbank() { + String cacheDir = Signlink.findcachedir(); + String[] fileCandidates = { + cacheDir + "soundfont.sf2", + cacheDir + "TimGM6mb.sf2", + "soundfont.sf2", + "TimGM6mb.sf2" + }; + for (String path : fileCandidates) { + File file = new File(path); + if (file.isFile() && file.canRead()) { + try { + return MidiSystem.getSoundbank(file); + } catch (Exception ignored) { + } + } + } + String[] resourceCandidates = {"/soundfont.sf2", "/TimGM6mb.sf2"}; + for (String res : resourceCandidates) { + try (InputStream in = Class56_Sub1_Sub1.class.getResourceAsStream(res)) { + if (in != null) { + return MidiSystem.getSoundbank(in); + } + } catch (Exception ignored) { + } + } + return null; + } + Class56_Sub1_Sub1() { - try { - aReceiver1850 = MidiSystem.getReceiver(); - aSequencer1851 = MidiSystem.getSequencer(false); - aSequencer1851.getTransmitter().setReceiver(this); - aSequencer1851.open(); - method838(-1L); - } catch (Exception exception) { - Game.method790(); - } + synchronized (MIDI_LOCK) { + try { + Soundbank customBank = loadCustomSoundbank(); + if (customBank != null) { + aSynthesizer = MidiSystem.getSynthesizer(); + aSynthesizer.open(); + if (aSynthesizer.isSoundbankSupported(customBank)) { + Soundbank def = aSynthesizer.getDefaultSoundbank(); + if (def != null) { + aSynthesizer.unloadAllInstruments(def); + } + aSynthesizer.loadAllInstruments(customBank); + } + aReceiver1850 = aSynthesizer.getReceiver(); + } else { + aReceiver1850 = MidiSystem.getReceiver(); + } + aSequencer1851 = MidiSystem.getSequencer(false); + aSequencer1851.getTransmitter().setReceiver(this); + aSequencer1851.open(); + method838(-1L); + } catch (Exception exception) { + closeResources(); + Game.method790(); + } + } } - + + private static void closeResources() { + if (aSequencer1851 != null) { + try { + if (aSequencer1851.isRunning()) { + aSequencer1851.stop(); + } + } catch (Exception ignored) { + } + try { + aSequencer1851.close(); + } catch (Exception ignored) { + } + aSequencer1851 = null; + } + synchronized (RECEIVER_LOCK) { + if (aReceiver1850 != null) { + try { + aReceiver1850.close(); + } catch (Exception ignored) { + } + aReceiver1850 = null; + } + if (aSynthesizer != null) { + try { + aSynthesizer.close(); + } catch (Exception ignored) { + } + aSynthesizer = null; + } + } + } + final void method828() { - if (aSequencer1851 != null) { - aSequencer1851.close(); - aSequencer1851 = null; - } - if (aReceiver1850 != null) { - aReceiver1850.close(); - aReceiver1850 = null; - } + synchronized (MIDI_LOCK) { + closeResources(); + } } - + public final void close() { - /* empty */ + /* empty */ } - + final void method831(int i) { - if (aSequencer1851 != null) { - method840(i, -1L); - } + synchronized (MIDI_LOCK) { + if (aSequencer1851 != null && aReceiver1850 != null) { + method840(i, -1L); + } + } } - - final synchronized void method830(int i, int i_2_) { - if (aSequencer1851 != null) { - method835(i_2_, i, -1L); - } + + final void method830(int i, int i_2_) { + synchronized (MIDI_LOCK) { + if (aSequencer1851 != null && aReceiver1850 != null) { + method835(i_2_, i, -1L); + } + } } - + final void method836(int i, int i_5_, int i_6_, long l) { - try { - ShortMessage shortmessage = new ShortMessage(); - shortmessage.setMessage(i, i_5_, i_6_); - aReceiver1850.send(shortmessage, l); - } catch (InvalidMidiDataException invalidmididataexception) { - /* empty */ - } + synchronized (RECEIVER_LOCK) { + if (aReceiver1850 == null) { + return; + } + try { + ShortMessage shortmessage = new ShortMessage(); + shortmessage.setMessage(i, i_5_, i_6_); + aReceiver1850.send(shortmessage, l); + } catch (InvalidMidiDataException invalidmididataexception) { + /* empty */ + } + } } - + final void method832(int i) { - if (i > -90) - method833(); + if (i > -90) { + method833(); + } } } diff --git a/2006Scape Client/src/main/java/Class56_Sub1_Sub2.java b/2006Scape Client/src/main/java/Class56_Sub1_Sub2.java index 5c2e9f4f..035f646e 100644 --- a/2006Scape Client/src/main/java/Class56_Sub1_Sub2.java +++ b/2006Scape Client/src/main/java/Class56_Sub1_Sub2.java @@ -28,6 +28,11 @@ final class Class56_Sub1_Sub2 extends Class56_Sub1 implements Runnable anInt1856 = 0; } } + + @Override + final synchronized void setLoop(boolean loop, boolean restartIfStopped) { + aBoolean1854 = loop; + } final void method836(int i, int i_4_, int i_5_, long l) { method845(i, (int) l, i_4_, i_5_); diff --git a/2006Scape Client/src/main/java/DesktopHooks.java b/2006Scape Client/src/main/java/DesktopHooks.java index 1d7d4021..6464869e 100644 --- a/2006Scape Client/src/main/java/DesktopHooks.java +++ b/2006Scape Client/src/main/java/DesktopHooks.java @@ -215,10 +215,8 @@ public final class DesktopHooks { public static Synthesizer synthesizer = null; public static Sequence sequence = null; - public static void playSignlinkMidi(String location, int midiVolume) { - music = null; - synthesizer = null; - sequence = null; + public static synchronized void playSignlinkMidi(String location, int midiVolume) { + stopSignlinkMidi(); File midiFile = new File(location); try { sequence = MidiSystem.getSequence(midiFile); @@ -257,12 +255,13 @@ public final class DesktopHooks { } int CHANGE_VOLUME = 7; if (synthesizer.getDefaultSoundbank() == null) { - try { + try (javax.sound.midi.Receiver receiver = MidiSystem.getReceiver()) { ShortMessage volumeMessage = new ShortMessage(); for (int i = 0; i < 16; i++) { volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, i, CHANGE_VOLUME, midiVolume); + receiver.send(volumeMessage, -1); volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, i, 39, midiVolume); - MidiSystem.getReceiver().send(volumeMessage, -1); + receiver.send(volumeMessage, -1); } } catch (Exception e) { e.printStackTrace(); @@ -283,14 +282,23 @@ public final class DesktopHooks { return true; } - public static void stopSignlinkMidi() { + public static synchronized void stopSignlinkMidi() { if (music != null) { try { - music.stop(); + if (music.isRunning()) { + music.stop(); + } music.close(); } catch (Exception ignored) {} music = null; } + if (synthesizer != null) { + try { + synthesizer.close(); + } catch (Exception ignored) {} + synthesizer = null; + } + sequence = null; } public static void showKeyboard() {} diff --git a/2006Scape Client/src/main/java/Game.java b/2006Scape Client/src/main/java/Game.java index c49afc2a..0f90d6e3 100644 --- a/2006Scape Client/src/main/java/Game.java +++ b/2006Scape Client/src/main/java/Game.java @@ -195,7 +195,7 @@ public class Game extends RSApplet { onDemandFetcher.method558(2, nextSong); musicVolume2 = volume; anInt139 = -1; - aBoolean995 = true; + aBoolean995 = !loggedIn || variousSettings[19] == 1; anInt116 = i_30_; } } @@ -206,7 +206,7 @@ public class Game extends RSApplet { onDemandFetcher.method558(2, nextSong); musicVolume2 = i; anInt139 = -1; - aBoolean995 = true; + aBoolean995 = bool && (!loggedIn || variousSettings[19] == 1); anInt116 = -1; } } @@ -1430,6 +1430,13 @@ public class Game extends RSApplet { } public void method33(int i) { + if (i == 19 && aClass56_749 != null) { + boolean loop = !loggedIn || variousSettings[19] == 1; + aBoolean995 = loop; + aBoolean475 = loop; + boolean restartIfStopped = loop && loggedIn && musicVolume != 0 && currentSong != -1 && previousSong == 0; + aClass56_749.setLoop(loop, restartIfStopped); + } int action = Varp.cache[i].anInt709; if (action == 0) { return; @@ -1472,7 +1479,7 @@ public class Game extends RSApplet { previousSong = 0; } } else { - method56(volume, false, currentSong); + method56(volume, true, currentSong); previousSong = 0;//TODO temp music } musicVolume = volume; @@ -6309,6 +6316,8 @@ public class Game extends RSApplet { super.awtFocus = true; aBoolean954 = true; loggedIn = true; + method55(false); + currentSong = -1; stream.currentOffset = 0; inStream.currentOffset = 0; pktType = -1; @@ -6671,7 +6680,7 @@ public class Game extends RSApplet { if (!flag1) { if (flag) { int i5 = 100; - for (int k5 = 1; k5 < 2; k5++) { + for (int k5 = 1; k5 < 11; k5++) { for (int i6 = k2 - k5; i6 <= k2 + k5; i6++) { for (int l6 = i2 - k5; l6 <= i2 + k5; l6++) { if (i6 >= 0 && l6 >= 0 && i6 < 104 && l6 < 104 && anIntArrayArray825[i6][l6] < i5) { @@ -7123,7 +7132,7 @@ public class Game extends RSApplet { if (previousSong < 0) previousSong = 0; if (previousSong == 0 && musicVolume != 0 && currentSong != -1) { - method56(musicVolume, false, currentSong); + method56(musicVolume, true, currentSong); } } } diff --git a/2006Scape Client/src/main/java/HdMaterial.java b/2006Scape Client/src/main/java/HdMaterial.java index 62d90d61..fd3562a7 100644 --- a/2006Scape Client/src/main/java/HdMaterial.java +++ b/2006Scape Client/src/main/java/HdMaterial.java @@ -118,21 +118,42 @@ public final class HdMaterial { boolean[] cutoutField = new boolean[layerPixels]; // 1. Build Layers 0..49 from RS2 Cache Textures + 317HD Architectural Enhancements + final int layerBytes = size * size * 4; for (int texId = 0; texId < 50; texId++) { buildCacheTextureLayer(texId, rgbField, heightField, cutoutField); - writeLayerToBuffers(texId, rgbField, heightField, cutoutField, get(texId).normalStrength, diffuseBuf, normalBuf); + writeLayerToBuffers(texId, texId * layerBytes, rgbField, heightField, cutoutField, get(texId).normalStrength, diffuseBuf, normalBuf); } // 2. Build Layers 50..63 (Dedicated 317HD Procedural PBR Materials) for (int matId = 50; matId < layers; matId++) { buildProceduralHdLayer(matId, rgbField, heightField, cutoutField); - writeLayerToBuffers(matId, rgbField, heightField, cutoutField, get(matId).normalStrength, diffuseBuf, normalBuf); + writeLayerToBuffers(matId, matId * layerBytes, rgbField, heightField, cutoutField, get(matId).normalStrength, diffuseBuf, normalBuf); } ((Buffer) diffuseBuf).position(0); ((Buffer) normalBuf).position(0); } + /** + * Populates a single 128x128 RGBA8 diffuse+heightfield and Sobel normal+specular layer at offset 0. + * Useful on memory-constrained platforms (e.g., Android) to stream layers via glTexSubImage3D. + */ + public static void populateSingleLayer(int layerId, ByteBuffer diffuseLayerBuf, ByteBuffer normalLayerBuf) { + final int layerPixels = TEX_SIZE * TEX_SIZE; + float[] heightField = new float[layerPixels]; + int[] rgbField = new int[layerPixels]; + boolean[] cutoutField = new boolean[layerPixels]; + + if (layerId < 50) { + buildCacheTextureLayer(layerId, rgbField, heightField, cutoutField); + } else { + buildProceduralHdLayer(layerId, rgbField, heightField, cutoutField); + } + writeLayerToBuffers(layerId, 0, rgbField, heightField, cutoutField, get(layerId).normalStrength, diffuseLayerBuf, normalLayerBuf); + ((Buffer) diffuseLayerBuf).position(0); + ((Buffer) normalLayerBuf).position(0); + } + private static void buildCacheTextureLayer(int texId, int[] rgbField, float[] heightField, boolean[] cutoutField) { int[] srcPixels = null; try { @@ -477,11 +498,10 @@ public final class HdMaterial { } } - private static void writeLayerToBuffers(int layerId, int[] rgbField, float[] heightField, boolean[] cutoutField, + private static void writeLayerToBuffers(int layerId, int baseOffset, int[] rgbField, float[] heightField, boolean[] cutoutField, float normalStrength, ByteBuffer diffuseBuf, ByteBuffer normalBuf) { final int size = TEX_SIZE; final int mask = size - 1; - int baseOffset = layerId * size * size * 4; ((Buffer) diffuseBuf).position(baseOffset); ((Buffer) normalBuf).position(baseOffset); diff --git a/2006Scape Client/src/main/java/SoundPlayer.java b/2006Scape Client/src/main/java/SoundPlayer.java index 7f201a81..4dee9d2c 100644 --- a/2006Scape Client/src/main/java/SoundPlayer.java +++ b/2006Scape Client/src/main/java/SoundPlayer.java @@ -1,77 +1,91 @@ import java.io.IOException; import java.io.InputStream; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; import javax.sound.sampled.*; public class SoundPlayer implements Runnable { - private AudioInputStream stream; - private DataLine.Info info; - private SourceDataLine sound; + private static final int BUFFER_SIZE = 4096; + private static final ExecutorService SOUND_EXECUTOR = Executors.newFixedThreadPool(4, new ThreadFactory() { + @Override + public Thread newThread(Runnable runnable) { + Thread t = new Thread(runnable, "SoundEffectPlayer"); + t.setDaemon(true); + return t; + } + }); - private InputStream soundStream; - private Thread player; - private int delay; - private int soundLevel; - public static int volume; + private final InputStream soundStream; + private final int delay; + private final int soundLevel; + public static volatile int volume; /** - * Initializes the sound player. + * Initializes and schedules the sound player. * @param stream * @param level * @param delay */ public SoundPlayer(InputStream stream, int level, int delay) { - if (level == 0 || volume == 4 || level - volume <= 0) { + if (stream == null || level <= 0 || volume >= 4 || level - volume <= 0) { + if (stream != null) { + try { + stream.close(); + } catch (IOException ignored) { + } + } + this.soundStream = null; + this.soundLevel = 0; + this.delay = 0; return; } this.soundStream = stream; this.soundLevel = level; this.delay = delay; - player = new Thread(this); - player.start(); + SOUND_EXECUTOR.execute(this); } /** * Plays the sound. */ + @Override public void run() { - try { - stream = AudioSystem.getAudioInputStream(soundStream); - + if (soundStream == null) { + return; + } + try (AudioInputStream stream = AudioSystem.getAudioInputStream(soundStream)) { AudioFormat format = stream.getFormat(); - info = new DataLine.Info(SourceDataLine.class, format); - sound = (SourceDataLine) AudioSystem.getLine(info); - sound.open(format); + DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); + try (SourceDataLine sound = (SourceDataLine) AudioSystem.getLine(info)) { + sound.open(format); - FloatControl volume = (FloatControl) sound.getControl(FloatControl.Type.MASTER_GAIN); - volume.setValue(getDecibels(soundLevel - getVolume())); - if (delay > 0) { - Thread.sleep(delay); - } - sound.start(); + if (sound.isControlSupported(FloatControl.Type.MASTER_GAIN)) { + FloatControl gainControl = (FloatControl) sound.getControl(FloatControl.Type.MASTER_GAIN); + float db = getDecibels(soundLevel - getVolume()); + db = Math.max(gainControl.getMinimum(), Math.min(gainControl.getMaximum(), db)); + gainControl.setValue(db); + } - int nBytesRead = 0; - int EXTERNAL_BUFFER_SIZE = 524288; - byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; - try { - while (nBytesRead != -1) { - nBytesRead = stream.read(abData, 0, abData.length); - if (nBytesRead >= 0) { - sound.write(abData, 0, nBytesRead); + if (delay > 0) { + Thread.sleep(delay); + } + sound.start(); + + byte[] buffer = new byte[BUFFER_SIZE]; + int nBytesRead; + while ((nBytesRead = stream.read(buffer, 0, buffer.length)) != -1) { + if (nBytesRead > 0) { + sound.write(buffer, 0, nBytesRead); } } - } catch (IOException e) { - e.printStackTrace(); - } finally { sound.drain(); - sound.close(); } - - stream.close(); - player.interrupt(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } catch (Exception e) { - player.interrupt(); e.printStackTrace(); } } @@ -97,19 +111,18 @@ public class SoundPlayer implements Runnable { * @return */ public float getDecibels(int level) { + if (level <= 0) { + return -1.0f; + } switch (level) { - case 0: // 4 in player options - return (float) -1.0f; - case 1: // 3 - return (float) -5.0f; + case 1: // 3 in player options + return -5.0f; case 2: // 2 - return (float) -10.0f; + return -10.0f; case 3: // 1 - return (float) -15.0f; - case 4: // off - return (float) -100.0f; - default: - return (float) 0.0f; + return -15.0f; + default: // 4+ (muted/off) + return -100.0f; } } -} \ No newline at end of file +} diff --git a/2006Scape Server/plugins/buttons/combat/AutocastCancelButtonPlugin.kt b/2006Scape Server/plugins/buttons/combat/AutocastCancelButtonPlugin.kt index 1d9c3d1f..90c7cb56 100644 --- a/2006Scape Server/plugins/buttons/combat/AutocastCancelButtonPlugin.kt +++ b/2006Scape Server/plugins/buttons/combat/AutocastCancelButtonPlugin.kt @@ -4,8 +4,8 @@ import com.rs2.event.EventContext import com.rs2.event.EventSubscriber import com.rs2.event.SubscribesTo import com.rs2.event.impl.ButtonActionEvent -import com.rs2.game.items.DeprecatedItems import com.rs2.game.players.Player +import org.apollo.cache.def.ItemDefinition @SubscribesTo(ButtonActionEvent::class) class AutocastCancelButtonPlugin : EventSubscriber { @@ -14,7 +14,12 @@ class AutocastCancelButtonPlugin : EventSubscriber { override fun subscribe(context: EventContext, player: Player, event: ButtonActionEvent) { if (player.isDead) return val weaponId = player.playerEquipment[player.playerWeapon] - player.itemAssistant.sendWeapon(weaponId, DeprecatedItems.getItemName(weaponId)) + val weaponName = if (weaponId == -1) { + "Unarmed" + } else { + ItemDefinition.lookup(weaponId)?.name ?: "Unarmed" + } + player.itemAssistant.sendWeapon(weaponId, weaponName) if (!player.autocasting) { player.packetSender.sendFrame36(43, player.fightMode) } diff --git a/2006Scape Server/plugins/buttons/gameframe/BrightnessButtons.java b/2006Scape Server/plugins/buttons/gameframe/BrightnessButtons.java deleted file mode 100644 index 9e9980f1..00000000 --- a/2006Scape Server/plugins/buttons/gameframe/BrightnessButtons.java +++ /dev/null @@ -1,35 +0,0 @@ -package plugin.buttons.gameframe; - -import com.rs2.event.SubscribesTo; -import com.rs2.event.impl.ButtonActionEvent; -import com.rs2.game.items.impl.LightSources; -import com.rs2.game.players.Player; -import plugin.buttons.ButtonClick; - -@SubscribesTo(ButtonActionEvent.class) -public final class BrightnessButtons extends ButtonClick { - - @Override - protected void execute(Player player, ButtonActionEvent event) { - switch (event.getButton()) { - case 3138: - LightSources.brightness1(player); - break; - case 3140: - LightSources.brightness2(player); - break; - case 3142: - LightSources.brightness3(player); - break; - case 3144: - LightSources.brightness4(player); - break; - - } - } - - @Override - public boolean test(ButtonActionEvent event) { - return event.getButton() == 3138 || event.getButton() == 3140 || event.getButton() == 3142 || event.getButton() == 3144; - } -} diff --git a/2006Scape Server/plugins/buttons/gameframe/GameOptionsPlugin.kt b/2006Scape Server/plugins/buttons/gameframe/GameOptionsPlugin.kt new file mode 100644 index 00000000..bfad2982 --- /dev/null +++ b/2006Scape Server/plugins/buttons/gameframe/GameOptionsPlugin.kt @@ -0,0 +1,125 @@ +package plugin.buttons.gameframe + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ButtonActionEvent +import com.rs2.game.content.music.Music +import com.rs2.game.items.impl.LightSources +import com.rs2.game.players.Player + +@SubscribesTo(ButtonActionEvent::class) +class GameOptionsPlugin : EventSubscriber { + + private data class ToggleOption( + val configId: Int, + val configValue: Int, + val apply: (Player) -> Unit + ) + + override fun test(event: ButtonActionEvent): Boolean = + event.button in BRIGHTNESS_ACTIONS || + event.button in TOGGLE_OPTIONS || + event.button in MUSIC_VOLUME_RANGE || + event.button in SOUND_VOLUME_RANGE + + override fun subscribe(context: EventContext, player: Player?, event: ButtonActionEvent) { + if (player == null) return + val button = event.button + + BRIGHTNESS_ACTIONS[button]?.let { action -> + action(player) + return + } + + TOGGLE_OPTIONS[button]?.let { option -> + option.apply(player) + player.packetSender.sendConfig(option.configId, option.configValue) + return + } + + when (button) { + in MUSIC_VOLUME_RANGE -> handleMusicVolume(player, MUSIC_VOLUME_RANGE.last - button) + in SOUND_VOLUME_RANGE -> handleSoundVolume(player, SOUND_VOLUME_RANGE.last - button) + } + } + + private fun handleMusicVolume(player: Player, level: Int) { + player.musicVolumeLevel = level + player.packetSender.sendConfig(CONFIG_MUSIC_VOLUME, level) + if (level == VOLUME_MUTED) { + if (player.musicOn) { + player.musicOn = false + player.addTemporary("CURRENT_SONG", NO_SONG) + } else { + player.packetSender.sendMessage("Your music is already turned off.") + } + } else { + player.musicOn = true + Music.playMusic(player) + } + } + + private fun handleSoundVolume(player: Player, level: Int) { + player.soundVolumeLevel = level + player.packetSender.sendConfig(CONFIG_SOUND_VOLUME, level) + if (level == VOLUME_MUTED) { + if (player.soundOn) { + player.soundOn = false + } else { + player.packetSender.sendMessage("Your sound is already turned off.") + } + } else { + player.soundOn = true + } + } + + private companion object { + const val BUTTON_BRIGHTNESS_1 = 3138 + const val BUTTON_BRIGHTNESS_2 = 3140 + const val BUTTON_BRIGHTNESS_3 = 3142 + const val BUTTON_BRIGHTNESS_4 = 3144 + + const val BUTTON_TWO_MOUSE_BUTTONS = 3145 + const val BUTTON_ONE_MOUSE_BUTTON = 3146 + const val BUTTON_CHAT_EFFECTS_ON = 3147 + const val BUTTON_CHAT_EFFECTS_OFF = 3148 + const val BUTTON_SPLIT_CHAT_ON = 3189 + const val BUTTON_SPLIT_CHAT_OFF = 3190 + const val BUTTON_ACCEPT_AID_ON = 48176 + const val BUTTON_ACCEPT_AID_OFF = 48177 + + val MUSIC_VOLUME_RANGE = 3162..3166 + val SOUND_VOLUME_RANGE = 3173..3177 + const val VOLUME_MUTED = 4 + const val NO_SONG = -1 + + const val CONFIG_MUSIC_VOLUME = 168 + const val CONFIG_SOUND_VOLUME = 169 + const val CONFIG_MOUSE_BUTTONS = 170 + const val CONFIG_CHAT_EFFECTS = 171 + const val CONFIG_SPLIT_CHAT = 287 + const val CONFIG_ACCEPT_AID = 427 + + const val STATE_OFF = 0 + const val STATE_ON = 1 + + val BRIGHTNESS_ACTIONS: Map Unit> = mapOf( + BUTTON_BRIGHTNESS_1 to LightSources::brightness1, + BUTTON_BRIGHTNESS_2 to LightSources::brightness2, + BUTTON_BRIGHTNESS_3 to LightSources::brightness3, + BUTTON_BRIGHTNESS_4 to LightSources::brightness4 + ) + + val TOGGLE_OPTIONS: Map = mapOf( + BUTTON_TWO_MOUSE_BUTTONS to ToggleOption(CONFIG_MOUSE_BUTTONS, STATE_OFF) { it.mouseButton = false }, + BUTTON_ONE_MOUSE_BUTTON to ToggleOption(CONFIG_MOUSE_BUTTONS, STATE_ON) { it.mouseButton = true }, + BUTTON_CHAT_EFFECTS_ON to ToggleOption(CONFIG_CHAT_EFFECTS, STATE_OFF) { it.chatEffects = true }, + BUTTON_CHAT_EFFECTS_OFF to ToggleOption(CONFIG_CHAT_EFFECTS, STATE_ON) { it.chatEffects = false }, + BUTTON_SPLIT_CHAT_ON to ToggleOption(CONFIG_SPLIT_CHAT, STATE_ON) { it.splitChat = true }, + BUTTON_SPLIT_CHAT_OFF to ToggleOption(CONFIG_SPLIT_CHAT, STATE_OFF) { it.splitChat = false }, + BUTTON_ACCEPT_AID_ON to ToggleOption(CONFIG_ACCEPT_AID, STATE_ON) { it.acceptAid = true }, + BUTTON_ACCEPT_AID_OFF to ToggleOption(CONFIG_ACCEPT_AID, STATE_OFF) { it.acceptAid = false } + ) + } +} diff --git a/2006Scape Server/plugins/buttons/gameframe/MusicVolumeButtons.java b/2006Scape Server/plugins/buttons/gameframe/MusicVolumeButtons.java deleted file mode 100644 index adb769bc..00000000 --- a/2006Scape Server/plugins/buttons/gameframe/MusicVolumeButtons.java +++ /dev/null @@ -1,38 +0,0 @@ -package plugin.buttons.gameframe; - -import com.rs2.event.SubscribesTo; -import com.rs2.event.impl.ButtonActionEvent; -import com.rs2.game.content.music.Music; -import com.rs2.game.players.Player; -import plugin.buttons.ButtonClick; - -@SubscribesTo(ButtonActionEvent.class) -public final class MusicVolumeButtons extends ButtonClick { - - @Override - protected void execute(Player player, ButtonActionEvent event) { - switch (event.getButton()) { - - case 3162: - if (player.musicOn) { - player.musicOn = false; - } else { - player.getPacketSender().sendMessage("Your music is already turned off."); - } - break; - case 3163: - case 3164: - case 3165: - case 3166: - Music.playMusic(player); - player.musicOn = true; - break; - } - } - - @Override - public boolean test(ButtonActionEvent event) { - return event.getButton() == 3162 || event.getButton() == 3163 || event.getButton() == 3164 || event.getButton() == 3165 || event.getButton() == 3166; - } - -} diff --git a/2006Scape Server/plugins/buttons/gameframe/SoundVolumeButtons.java b/2006Scape Server/plugins/buttons/gameframe/SoundVolumeButtons.java deleted file mode 100644 index 7cc42b6f..00000000 --- a/2006Scape Server/plugins/buttons/gameframe/SoundVolumeButtons.java +++ /dev/null @@ -1,37 +0,0 @@ -package plugin.buttons.gameframe; - -import com.rs2.event.SubscribesTo; -import com.rs2.event.impl.ButtonActionEvent; -import com.rs2.game.content.music.Music; -import com.rs2.game.players.Player; -import plugin.buttons.ButtonClick; - -@SubscribesTo(ButtonActionEvent.class) -public final class SoundVolumeButtons extends ButtonClick { - - @Override - protected void execute(Player player, ButtonActionEvent event) { - switch (event.getButton()) { - - case 3173: - if (player.soundOn) { - player.soundOn = false; - } else { - player.getPacketSender().sendMessage("Your sound is already turned off."); - } - break; - case 3174: - case 3175: - case 3176: - case 3177: - player.soundOn = true; - break; - } - } - - @Override - public boolean test(ButtonActionEvent event) { - return event.getButton() == 3173 || event.getButton() == 3174 || event.getButton() == 3175 || event.getButton() == 3176 || event.getButton() == 3177; - } - -} diff --git a/2006Scape Server/plugins/buttons/gameframe/ToggleSplitChatButtons.java b/2006Scape Server/plugins/buttons/gameframe/ToggleSplitChatButtons.java deleted file mode 100644 index 2ce5896f..00000000 --- a/2006Scape Server/plugins/buttons/gameframe/ToggleSplitChatButtons.java +++ /dev/null @@ -1,34 +0,0 @@ -package plugin.buttons.gameframe; - -import com.rs2.event.SubscribesTo; -import com.rs2.event.impl.ButtonActionEvent; -import com.rs2.game.players.Player; -import plugin.buttons.ButtonClick; - -@SubscribesTo(ButtonActionEvent.class) -public final class ToggleSplitChatButtons extends ButtonClick { - - @Override - protected void execute(Player player, ButtonActionEvent event) { - switch (event.getButton()) { - - case 3189: - player.getPacketSender().sendConfig(502, 1); - player.getPacketSender().sendConfig(287, 1); - player.splitChat = true; - break; - case 3190: - player.getPacketSender().sendConfig(502, 0); - player.getPacketSender().sendConfig(287, 0); - player.splitChat = false; - break; - - } - } - - @Override - public boolean test(ButtonActionEvent event) { - return event.getButton() == 3189 || event.getButton() == 3190; - } - -} \ No newline at end of file diff --git a/2006Scape Server/plugins/commands/RandomToggle.kt b/2006Scape Server/plugins/commands/RandomToggle.kt new file mode 100644 index 00000000..1b372417 --- /dev/null +++ b/2006Scape Server/plugins/commands/RandomToggle.kt @@ -0,0 +1,25 @@ +package plugin.commands + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.CommandEvent +import com.rs2.game.players.Player + +@SubscribesTo(CommandEvent::class) +class RandomToggle : EventSubscriber { + + override fun test(event: CommandEvent): Boolean = + event.name.equals("random", ignoreCase = true) || + event.name.equals("randomtoggle", ignoreCase = true) || + event.name.equals("togglerandom", ignoreCase = true) + + override fun subscribe(context: EventContext, player: Player?, event: CommandEvent) { + if (player == null) return + + context.breakSubscriberChain() + player.randomEventsEnabled = !player.randomEventsEnabled + val stateText = if (player.randomEventsEnabled) "now" else "no longer" + player.packetSender.sendMessage("You will $stateText receive random events.") + } +} diff --git a/2006Scape Server/plugins/commands/admin/Teleport.kt b/2006Scape Server/plugins/commands/admin/Teleport.kt index a3267a22..3683bd86 100644 --- a/2006Scape Server/plugins/commands/admin/Teleport.kt +++ b/2006Scape Server/plugins/commands/admin/Teleport.kt @@ -59,7 +59,8 @@ class Teleport : EventSubscriber { "port sarim" to Triple(3041, 3202, 0), "rellekka" to Triple(2620, 3686, 0), "brimhaven" to Triple(2772, 3234, 0), - "entrana" to Triple(2834, 3335, 0) + "entrana" to Triple(2834, 3335, 0), + "zanaris" to Triple(2452, 4470, 0) ) private val VALID_CITIES_MESSAGES = listOf( @@ -70,7 +71,7 @@ class Teleport : EventSubscriber { " dareeyak, carrallangar, annakarl, ghorrock", "Other: barrows, taverley (tav), edgeville (edge), al kharid, karamja,", " draynor, duel arena (duel), castle wars (cw), pest control (pc),", - " port sarim, rellekka, brimhaven, entrana" + " port sarim, rellekka, brimhaven, entrana, zanaris" ) } diff --git a/2006Scape Server/plugins/commands/developer/TriggerRandomEvent.kt b/2006Scape Server/plugins/commands/developer/TriggerRandomEvent.kt new file mode 100644 index 00000000..fd201767 --- /dev/null +++ b/2006Scape Server/plugins/commands/developer/TriggerRandomEvent.kt @@ -0,0 +1,78 @@ +package plugin.commands.developer + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.DeveloperCommandEvent +import com.rs2.game.players.Player +import plugin.game.content.randomevents.CombatRandoms +import plugin.game.content.randomevents.FreakyForesterPlugin +import plugin.game.content.randomevents.FrogPlugin +import plugin.game.content.randomevents.GeniePlugin +import plugin.game.content.randomevents.SandwichLadyPlugin +import plugin.game.content.randomevents.ZanarisChoirPlugin + +@SubscribesTo(DeveloperCommandEvent::class) +class TriggerRandomEvent : EventSubscriber { + + companion object { + private const val LINE_1 = "sandwich, chicken, forester, swarm, genie, frog" + private const val LINE_2 = "troll, golem, spirit, shade, zombie, choir" + } + + override fun test(event: DeveloperCommandEvent): Boolean = + event.name.equals("randomevent", ignoreCase = true) || + event.name.equals("randomevents", ignoreCase = true) || + event.name.equals("revent", ignoreCase = true) + + override fun subscribe(context: EventContext, player: Player?, event: DeveloperCommandEvent) { + if (player == null) return + + context.breakSubscriberChain() + val target = event.arguments.firstOrNull()?.lowercase() + if (target == null || target == "help") { + player.packetSender.sendMessage("Usage: ::randomevent ") + player.packetSender.sendMessage("Events: $LINE_1") + player.packetSender.sendMessage(" $LINE_2") + return + } + + if ((target == "choir" || target == "zanarischoir") && !ZanarisChoirPlugin.isInZanaris(player)) { + player.packetSender.sendMessage("Zanaris Choir only spawns in Zanaris (::tele zanaris).") + return + } + + val triggered = when (target) { + "sandwich", "sandwichlady" -> SandwichLadyPlugin.spawn(player) + "chicken", "evilchicken" -> CombatRandoms.spawnEvilChicken(player) + "forester", "freakyforester" -> { + FreakyForesterPlugin.teleportToLocation(player) + true + } + "swarm" -> { + CombatRandoms.spawnSwarm(player) + true + } + "genie" -> GeniePlugin.spawn(player) + "frog", "frogs" -> FrogPlugin.startEvent(player) + "troll", "rivertroll" -> CombatRandoms.spawnRiverTroll(player) + "golem", "rockgolem" -> CombatRandoms.spawnRockGolem(player) + "spirit", "treespirit" -> CombatRandoms.spawnTreeSpirit(player) + "shade" -> CombatRandoms.spawnShade(player) + "zombie" -> CombatRandoms.spawnZombie(player) + "choir", "zanarischoir" -> ZanarisChoirPlugin.spawn(player) + else -> { + player.packetSender.sendMessage("Unknown random event '$target'.") + player.packetSender.sendMessage("Events: $LINE_1") + player.packetSender.sendMessage(" $LINE_2") + return + } + } + + if (triggered) { + player.packetSender.sendMessage("Triggered random event: $target") + } else { + player.packetSender.sendMessage("Could not trigger '$target' here (already active or restricted area).") + } + } +} diff --git a/2006Scape Server/plugins/commands/developer/UnlockSongs.kt b/2006Scape Server/plugins/commands/developer/UnlockSongs.kt new file mode 100644 index 00000000..5c004fc2 --- /dev/null +++ b/2006Scape Server/plugins/commands/developer/UnlockSongs.kt @@ -0,0 +1,27 @@ +package plugin.commands.developer + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.DeveloperCommandEvent +import com.rs2.game.players.Player + +@SubscribesTo(DeveloperCommandEvent::class) +class UnlockSongs : EventSubscriber { + + override fun test(event: DeveloperCommandEvent): Boolean = + event.name.equals("unlocksongs", ignoreCase = true) || + event.name.equals("unlockmusic", ignoreCase = true) || + event.name.equals("allsongs", ignoreCase = true) + + override fun subscribe(context: EventContext, player: Player?, event: DeveloperCommandEvent) { + if (player == null) return + + context.breakSubscriberChain() + + val playList = player.playList + playList.unlocked.fill(true) + playList.sendMusicConfigs() + player.packetSender.sendMessage("Unlocked all ${playList.unlocked.size} songs in your music player.") + } +} diff --git a/2006Scape Server/plugins/game/content/items/lamps/LampInterfaceSupport.kt b/2006Scape Server/plugins/game/content/items/lamps/LampInterfaceSupport.kt new file mode 100644 index 00000000..bbee3cba --- /dev/null +++ b/2006Scape Server/plugins/game/content/items/lamps/LampInterfaceSupport.kt @@ -0,0 +1,117 @@ +package plugin.game.content.items.lamps + +import com.rs2.Constants +import com.rs2.game.players.Player +import com.rs2.game.players.PlayerAssistant + +object LampInterfaceSupport { + const val PLUGIN_DATA_KEY = "lamps" + const val ACTIVE_LAMP_KEY = "activeLampId" + const val SELECTED_SKILL_KEY = "selectedSkill" + const val SKILL_MENU_INTERFACE = 2808 + const val CONFIRM_BUTTON = 11015 + const val LAMP_SELECTION_CONFIG = 261 + + data class SkillButton(val buttonId: Int, val skillId: Int, val skillName: String, val configValue: Int) + + val SKILL_BUTTONS: Map = listOf( + SkillButton(10252, 0, "Attack", 1), + SkillButton(10253, 2, "Strength", 2), + SkillButton(10254, 4, "Ranged", 3), + SkillButton(10255, 6, "Magic", 4), + SkillButton(11000, 1, "Defence", 5), + SkillButton(11001, 3, "Hitpoints", 6), + SkillButton(11002, 5, "Prayer", 7), + SkillButton(11003, 16, "Agility", 8), + SkillButton(11004, 15, "Herblore", 9), + SkillButton(11005, 17, "Thieving", 10), + SkillButton(11006, 12, "Crafting", 11), + SkillButton(11007, 20, "Runecrafting", 12), + SkillButton(11008, 14, "Mining", 13), + SkillButton(11009, 13, "Smithing", 14), + SkillButton(11010, 10, "Fishing", 15), + SkillButton(11011, 7, "Cooking", 16), + SkillButton(11012, 11, "Firemaking", 17), + SkillButton(11013, 8, "Woodcutting", 18), + SkillButton(11014, 9, "Fletching", 19), + SkillButton(47002, 18, "Slayer", 20), + SkillButton(54090, 19, "Farming", 21) + ).associateBy { it.buttonId } + + fun isLampButton(buttonId: Int): Boolean { + return buttonId == CONFIRM_BUTTON || SKILL_BUTTONS.containsKey(buttonId) + } + + fun openLampInterface(player: Player, itemId: Int, message: String) { + player.pluginData.putInt(PLUGIN_DATA_KEY, ACTIVE_LAMP_KEY, itemId) + player.pluginData.putInt(PLUGIN_DATA_KEY, SELECTED_SKILL_KEY, -1) + player.packetSender.sendConfig(LAMP_SELECTION_CONFIG, 0) + player.packetSender.sendMessage(message) + player.packetSender.showInterface(SKILL_MENU_INTERFACE) + } + + fun handleLampButton( + player: Player, + expectedItemId: Int, + buttonId: Int, + minLevel: Int = 1, + allowedSkills: Set? = null, + baseXpProvider: (Int) -> Int + ) { + if (player.pluginData.getInt(PLUGIN_DATA_KEY, ACTIVE_LAMP_KEY, -1) != expectedItemId) { + return + } + + val skillButton = SKILL_BUTTONS[buttonId] + if (skillButton != null) { + if (allowedSkills != null && skillButton.skillId !in allowedSkills) { + player.pluginData.putInt(PLUGIN_DATA_KEY, SELECTED_SKILL_KEY, -1) + player.packetSender.sendConfig(LAMP_SELECTION_CONFIG, 0) + player.packetSender.sendMessage("You can only use this lamp on combat skills.") + return + } + val level = PlayerAssistant.getLevelForXP(player.playerXP[skillButton.skillId]) + if (level < minLevel) { + player.pluginData.putInt(PLUGIN_DATA_KEY, SELECTED_SKILL_KEY, -1) + player.packetSender.sendConfig(LAMP_SELECTION_CONFIG, 0) + player.packetSender.sendMessage("You need at least level $minLevel in ${skillButton.skillName} to use this lamp.") + return + } + player.pluginData.putInt(PLUGIN_DATA_KEY, SELECTED_SKILL_KEY, skillButton.skillId) + player.packetSender.sendConfig(LAMP_SELECTION_CONFIG, skillButton.configValue) + player.packetSender.sendMessage("You select ${skillButton.skillName}.") + return + } + + if (buttonId == CONFIRM_BUTTON) { + val skill = player.pluginData.getInt(PLUGIN_DATA_KEY, SELECTED_SKILL_KEY, -1) + if (skill < 0) { + player.packetSender.closeAllWindows() + return + } + if (allowedSkills != null && skill !in allowedSkills) { + player.packetSender.sendMessage("You can only use this lamp on combat skills.") + return + } + val level = PlayerAssistant.getLevelForXP(player.playerXP[skill]) + if (level < minLevel) { + player.packetSender.sendMessage("You need at least level $minLevel in that skill to use this lamp.") + return + } + if (!player.itemAssistant.playerHasItem(expectedItemId, 1)) { + return + } + + val baseXp = baseXpProvider(level) + val multiplier = if (Constants.VARIABLE_XP_RATE) player.xpRate.toDouble() else Constants.XP_RATE.toDouble() + player.playerAssistant.addSkillXP(baseXp.toDouble(), skill) + player.itemAssistant.deleteItem(expectedItemId, 1) + player.packetSender.sendMessage("@blu@Your wish has been granted!") + player.packetSender.sendMessage("@blu@You have been awarded ${(baseXp * multiplier).toInt()} experience in your selected skill!") + player.packetSender.closeAllWindows() + player.packetSender.sendConfig(LAMP_SELECTION_CONFIG, 0) + player.pluginData.putInt(PLUGIN_DATA_KEY, ACTIVE_LAMP_KEY, -1) + player.pluginData.putInt(PLUGIN_DATA_KEY, SELECTED_SKILL_KEY, -1) + } + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/CombatRandoms.kt b/2006Scape Server/plugins/game/content/randomevents/CombatRandoms.kt new file mode 100644 index 00000000..9c9a751c --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/CombatRandoms.kt @@ -0,0 +1,216 @@ +package plugin.game.content.randomevents + +import com.rs2.Constants +import com.rs2.game.content.StaticNpcList.EVIL_CHICKEN +import com.rs2.game.content.StaticNpcList.EVIL_CHICKEN_2464 +import com.rs2.game.content.StaticNpcList.EVIL_CHICKEN_2465 +import com.rs2.game.content.StaticNpcList.EVIL_CHICKEN_2466 +import com.rs2.game.content.StaticNpcList.EVIL_CHICKEN_2467 +import com.rs2.game.content.StaticNpcList.EVIL_CHICKEN_2468 +import com.rs2.game.content.StaticNpcList.RIVER_TROLL +import com.rs2.game.content.StaticNpcList.RIVER_TROLL_392 +import com.rs2.game.content.StaticNpcList.RIVER_TROLL_393 +import com.rs2.game.content.StaticNpcList.RIVER_TROLL_394 +import com.rs2.game.content.StaticNpcList.RIVER_TROLL_395 +import com.rs2.game.content.StaticNpcList.RIVER_TROLL_396 +import com.rs2.game.content.StaticNpcList.ROCK_GOLEM +import com.rs2.game.content.StaticNpcList.ROCK_GOLEM_414 +import com.rs2.game.content.StaticNpcList.ROCK_GOLEM_415 +import com.rs2.game.content.StaticNpcList.ROCK_GOLEM_416 +import com.rs2.game.content.StaticNpcList.ROCK_GOLEM_417 +import com.rs2.game.content.StaticNpcList.ROCK_GOLEM_418 +import com.rs2.game.content.StaticNpcList.SHADE +import com.rs2.game.content.StaticNpcList.SHADE_426 +import com.rs2.game.content.StaticNpcList.SHADE_427 +import com.rs2.game.content.StaticNpcList.SHADE_428 +import com.rs2.game.content.StaticNpcList.SHADE_429 +import com.rs2.game.content.StaticNpcList.SHADE_430 +import com.rs2.game.content.StaticNpcList.SWARM +import com.rs2.game.content.StaticNpcList.TREE_SPIRIT +import com.rs2.game.content.StaticNpcList.TREE_SPIRIT_439 +import com.rs2.game.content.StaticNpcList.TREE_SPIRIT_440 +import com.rs2.game.content.StaticNpcList.TREE_SPIRIT_441 +import com.rs2.game.content.StaticNpcList.TREE_SPIRIT_442 +import com.rs2.game.content.StaticNpcList.TREE_SPIRIT_443 +import com.rs2.game.content.StaticNpcList.ZOMBIE_419 +import com.rs2.game.content.StaticNpcList.ZOMBIE_420 +import com.rs2.game.content.StaticNpcList.ZOMBIE_421 +import com.rs2.game.content.StaticNpcList.ZOMBIE_422 +import com.rs2.game.content.StaticNpcList.ZOMBIE_423 +import com.rs2.game.content.StaticNpcList.ZOMBIE_424 +import com.rs2.game.npcs.NpcHandler +import com.rs2.game.players.Player +import com.rs2.game.players.PlayerAssistant +import plugin.game.content.randomevents.RandomEventSupport.CombatNpcTier + +object CombatRandoms { + + private val EVIL_CHICKEN_TIERS = listOf( + CombatNpcTier(3, 10, EVIL_CHICKEN, 19, 1, 10, 10), + CombatNpcTier(11, 20, EVIL_CHICKEN_2464, 40, 1, 30, 30), + CombatNpcTier(21, 40, EVIL_CHICKEN_2465, 60, 2, 60, 60), + CombatNpcTier(41, 60, EVIL_CHICKEN_2466, 80, 3, 80, 80), + CombatNpcTier(61, 90, EVIL_CHICKEN_2467, 105, 4, 100, 100), + CombatNpcTier(91, 138, EVIL_CHICKEN_2468, 120, 5, 120, 120) + ) + + private val RIVER_TROLL_TIERS = listOf( + CombatNpcTier(3, 10, RIVER_TROLL, 19, 1), + CombatNpcTier(11, 20, RIVER_TROLL_392, 40, 1), + CombatNpcTier(21, 60, RIVER_TROLL_393, 80, 3), + CombatNpcTier(61, 90, RIVER_TROLL_394, 105, 4), + CombatNpcTier(91, 110, RIVER_TROLL_395, 120, 5), + CombatNpcTier(111, 138, RIVER_TROLL_396, 150, 7) + ) + + private val ROCK_GOLEM_TIERS = listOf( + CombatNpcTier(3, 10, ROCK_GOLEM, 19, 1), + CombatNpcTier(11, 20, ROCK_GOLEM_414, 40, 1), + CombatNpcTier(21, 60, ROCK_GOLEM_415, 80, 3), + CombatNpcTier(61, 90, ROCK_GOLEM_416, 105, 4), + CombatNpcTier(91, 110, ROCK_GOLEM_417, 120, 5), + CombatNpcTier(111, 138, ROCK_GOLEM_418, 150, 7) + ) + + private val TREE_SPIRIT_TIERS = listOf( + CombatNpcTier(3, 10, TREE_SPIRIT, 28, 1), + CombatNpcTier(11, 20, TREE_SPIRIT_439, 36, 1), + CombatNpcTier(21, 60, TREE_SPIRIT_440, 57, 3), + CombatNpcTier(61, 90, TREE_SPIRIT_441, 90, 4), + CombatNpcTier(91, 110, TREE_SPIRIT_442, 130, 5), + CombatNpcTier(111, 138, TREE_SPIRIT_443, 160, 7) + ) + + private val SHADE_TIERS = listOf( + CombatNpcTier(3, 10, SHADE, 19, 1), + CombatNpcTier(11, 20, SHADE_426, 40, 3), + CombatNpcTier(21, 40, SHADE_427, 60, 5), + CombatNpcTier(41, 60, SHADE_428, 80, 8), + CombatNpcTier(61, 90, SHADE_429, 105, 11), + CombatNpcTier(91, 138, SHADE_430, 120, 13) + ) + + private val ZOMBIE_TIERS = listOf( + CombatNpcTier(3, 10, ZOMBIE_419, 28, 2, 10, 10), + CombatNpcTier(11, 20, ZOMBIE_420, 36, 4, 20, 20), + CombatNpcTier(21, 60, ZOMBIE_421, 57, 6, 30, 30), + CombatNpcTier(61, 90, ZOMBIE_422, 90, 8, 40, 40), + CombatNpcTier(91, 110, ZOMBIE_423, 130, 10, 50, 50), + CombatNpcTier(111, 138, ZOMBIE_424, 160, 12, 60, 60) + ) + + fun spawnEvilChicken(player: Player): Boolean { + val state = RandomEventSupport.state(player) + if (RandomEventSupport.isNpcActive(player, state.chickenNpcSlot)) return false + val npc = RandomEventSupport.spawnScaledCombatNpc( + player, + EVIL_CHICKEN_TIERS, + forceChat = "Bwuk bwuk bwuk!" + ) ?: return false + state.chickenNpcSlot = npc.npcId + RandomEventSupport.resetRandomActions(player) + return true + } + + fun spawnRiverTroll(player: Player): Boolean { + val state = RandomEventSupport.state(player) + if (RandomEventSupport.isNpcActive(player, state.riverTrollNpcSlot)) return false + val npc = RandomEventSupport.spawnScaledCombatNpc( + player, + RIVER_TROLL_TIERS, + forceChat = "Fishies be mine! Leave dem fishies!", + attackOverride = { p, _ -> p.playerLevel[Constants.ATTACK] * 2 }, + defenceOverride = { p, _ -> p.playerLevel[Constants.DEFENCE] * 2 } + ) ?: return false + state.riverTrollNpcSlot = npc.npcId + RandomEventSupport.resetRandomActions(player) + return true + } + + fun spawnRockGolem(player: Player): Boolean { + val state = RandomEventSupport.state(player) + if (RandomEventSupport.isNpcActive(player, state.rockGolemNpcSlot)) return false + val npc = RandomEventSupport.spawnScaledCombatNpc( + player, + ROCK_GOLEM_TIERS, + forceChat = "Raarrrgghh! Flee human!" + ) ?: return false + state.rockGolemNpcSlot = npc.npcId + RandomEventSupport.resetRandomActions(player) + return true + } + + fun spawnTreeSpirit(player: Player): Boolean { + val state = RandomEventSupport.state(player) + if (RandomEventSupport.isNpcActive(player, state.treeSpiritNpcSlot)) return false + val npc = RandomEventSupport.spawnScaledCombatNpc( + player, + TREE_SPIRIT_TIERS, + forceChat = "Leave these woods and never return!", + attackOverride = { p, _ -> PlayerAssistant.getLevelForXP(p.playerXP[Constants.HITPOINTS]) * 2 }, + defenceOverride = { p, _ -> p.playerLevel[Constants.DEFENCE] * 2 } + ) ?: return false + state.treeSpiritNpcSlot = npc.npcId + RandomEventSupport.resetRandomActions(player) + return true + } + + fun spawnShade(player: Player): Boolean { + val state = RandomEventSupport.state(player) + if (RandomEventSupport.isNpcActive(player, state.shadeNpcSlot)) return false + val npc = RandomEventSupport.spawnScaledCombatNpc( + player, + SHADE_TIERS, + attackOverride = { _, tier -> (NpcHandler.getNpcListCombat(tier.npcId) * 1.5).toInt().coerceAtLeast(10) }, + defenceOverride = { _, tier -> (NpcHandler.getNpcListCombat(tier.npcId) * 1.5).toInt().coerceAtLeast(10) } + ) ?: return false + state.shadeNpcSlot = npc.npcId + RandomEventSupport.resetRandomActions(player) + return true + } + + fun spawnZombie(player: Player): Boolean { + val state = RandomEventSupport.state(player) + if (RandomEventSupport.isNpcActive(player, state.zombieNpcSlot)) return false + val npc = RandomEventSupport.spawnScaledCombatNpc( + player, + ZOMBIE_TIERS, + forceChat = "Braaaainssss!" + ) ?: return false + state.zombieNpcSlot = npc.npcId + RandomEventSupport.resetRandomActions(player) + return true + } + + fun spawnSwarm(player: Player) { + val hpLevel = PlayerAssistant.getLevelForXP(player.playerXP[Constants.HITPOINTS]) + val (spawnX, spawnY) = RandomEventSupport.findSpawnTile(player) + NpcHandler.spawnNpcReturn( + player, + SWARM, + spawnX, + spawnY, + player.heightLevel, + 0, + 1, + 2, + hpLevel * 2, + 3 * player.combatLevel, + true, + false + ) + player.autoRet = 0 + } + + fun onNpcDeath(player: Player, npcType: Int) { + val state = RandomEventSupport.state(player) + when (npcType) { + in EVIL_CHICKEN..EVIL_CHICKEN_2468 -> state.chickenNpcSlot = -1 + in RIVER_TROLL..RIVER_TROLL_396 -> state.riverTrollNpcSlot = -1 + in ROCK_GOLEM..ROCK_GOLEM_418 -> state.rockGolemNpcSlot = -1 + in TREE_SPIRIT..TREE_SPIRIT_443 -> state.treeSpiritNpcSlot = -1 + in SHADE..SHADE_430 -> state.shadeNpcSlot = -1 + in ZOMBIE_419..ZOMBIE_424 -> state.zombieNpcSlot = -1 + } + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/FreakyForesterPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/FreakyForesterPlugin.kt new file mode 100644 index 00000000..0655ff42 --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/FreakyForesterPlugin.kt @@ -0,0 +1,132 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.NpcFirstClickEvent +import com.rs2.game.content.StaticItemList.COINS +import com.rs2.game.content.StaticItemList.LEDERHOSEN_HAT +import com.rs2.game.content.StaticItemList.LEDERHOSEN_SHORTS +import com.rs2.game.content.StaticItemList.LEDERHOSEN_TOP +import com.rs2.game.content.StaticItemList.RAW_PHEASANT +import com.rs2.game.content.StaticNpcList.FREAKY_FORESTER +import com.rs2.game.players.Player +import com.rs2.util.Misc + +@SubscribesTo(NpcFirstClickEvent::class) +class FreakyForesterPlugin : EventSubscriber { + + companion object { + private val PHEASANT_NAMES = arrayOf("one", "two", "three", "four") + + fun teleportToLocation(player: Player) { + player.lastX = player.absX + player.lastY = player.absY + player.lastH = player.heightLevel + player.teleportToX = 2602 + player.teleportToY = 4775 + player.heightLevel = 0 + player.packetSender.sendMessage("Talk to the freaky forester to get out.") + } + + fun getPheasantDescription(player: Player): String { + val state = RandomEventSupport.state(player) + if (state.foresterTargetPheasant < 0) { + state.foresterTargetPheasant = Misc.random(3) + } + return "${PHEASANT_NAMES[state.foresterTargetPheasant]} tailed" + } + + fun onPheasantKilled(player: Player, pheasantIndex: Int) { + val state = RandomEventSupport.state(player) + state.foresterKilledPheasant.fill(false) + if (pheasantIndex in state.foresterKilledPheasant.indices) { + state.foresterKilledPheasant[pheasantIndex] = true + } + } + + fun hasKilledAnyPheasant(player: Player): Boolean { + val state = RandomEventSupport.state(player) + val killed = state.foresterKilledPheasant.any { it } + state.foresterCanLeave = killed + return killed + } + + fun leaveArea(player: Player) { + val state = RandomEventSupport.state(player) + val target = state.foresterTargetPheasant + if (target in state.foresterKilledPheasant.indices && state.foresterKilledPheasant[target]) { + val returnX = if (player.lastX > 0) player.lastX else 3222 + val returnY = if (player.lastY > 0) player.lastY else 3218 + val returnH = if (player.lastX > 0) player.lastH else 0 + player.playerAssistant.movePlayer(returnX, returnY, returnH) + player.packetSender.sendMessage("Congratulations, you've completed the freaky forester event!") + val alreadyRewarded = player.pluginData.getBoolean( + RandomEventSupport.PLUGIN_ID, + RandomEventSupport.FORESTER_REWARDED_KEY, + false + ) + if (!alreadyRewarded) { + player.itemAssistant.addItem(LEDERHOSEN_TOP, 1) + player.itemAssistant.addItem(LEDERHOSEN_SHORTS, 1) + player.itemAssistant.addItem(LEDERHOSEN_HAT, 1) + player.pluginData.putBoolean( + RandomEventSupport.PLUGIN_ID, + RandomEventSupport.FORESTER_REWARDED_KEY, + true + ) + } else { + player.itemAssistant.addItem(COINS, 500) + player.packetSender.sendMessage("You have already beat the freaky forester event so you get 500 coins.") + } + val rawCount = player.itemAssistant.getItemAmount(RAW_PHEASANT) + if (rawCount > 0) { + player.itemAssistant.deleteItem(RAW_PHEASANT, rawCount) + } + RandomEventSupport.resetRandomActions(player) + } else { + RandomEventSupport.failEvent(player) + } + state.foresterKilledPheasant.fill(false) + state.foresterTargetPheasant = -1 + state.foresterCanLeave = false + } + } + + override fun test(event: NpcFirstClickEvent) = event.npc == FREAKY_FORESTER + + override fun subscribe(context: EventContext, player: Player, event: NpcFirstClickEvent) { + val state = RandomEventSupport.state(player) + val dialogue = player.dialogueFactory + dialogue.clear() + + if (state.foresterCanLeave) { + deleteAllRawPheasants(player) + dialogue.sendNpcChat( + FREAKY_FORESTER, + "Just step through the glowing portal when you're ready", + "to leave, and I'll ensure you get a nice reward." + ).execute() + } else if (hasKilledAnyPheasant(player) && player.itemAssistant.playerHasItem(RAW_PHEASANT, 1)) { + state.foresterCanLeave = true + deleteAllRawPheasants(player) + dialogue.sendNpcChat( + FREAKY_FORESTER, + "Thank you. I take that pheasant, you can leave now." + ).execute() + } else { + dialogue.sendNpcChat( + FREAKY_FORESTER, + "Hello there mate. Can you please kill a ${getPheasantDescription(player)} and", + "bring it back to me and I shall let you leave." + ).execute() + } + } + + private fun deleteAllRawPheasants(player: Player) { + val amount = player.itemAssistant.getItemAmount(RAW_PHEASANT) + if (amount > 0) { + player.itemAssistant.deleteItem(RAW_PHEASANT, amount) + } + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/FreakyForesterPortalPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/FreakyForesterPortalPlugin.kt new file mode 100644 index 00000000..a1bd9380 --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/FreakyForesterPortalPlugin.kt @@ -0,0 +1,30 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ObjectFirstClickEvent +import com.rs2.game.content.StaticNpcList.FREAKY_FORESTER +import com.rs2.game.players.Player + +@SubscribesTo(ObjectFirstClickEvent::class) +class FreakyForesterPortalPlugin : EventSubscriber { + + companion object { + private const val EXIT_PORTAL_OBJECT_ID = 8972 + } + + override fun test(event: ObjectFirstClickEvent) = event.gameObject == EXIT_PORTAL_OBJECT_ID + + override fun subscribe(context: EventContext, player: Player, event: ObjectFirstClickEvent) { + val state = RandomEventSupport.state(player) + if (!state.foresterCanLeave) { + val dialogue = player.dialogueFactory + dialogue.clear() + dialogue.sendNpcChat(FREAKY_FORESTER, "Come back mate! You can't leave yet!") + .execute() + } else { + FreakyForesterPlugin.leaveArea(player) + } + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/FrogPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/FrogPlugin.kt new file mode 100644 index 00000000..84e11d26 --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/FrogPlugin.kt @@ -0,0 +1,125 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.NpcFirstClickEvent +import com.rs2.game.content.StaticItemList.FROG_TOKEN +import com.rs2.game.content.StaticNpcList.FROG_2469 +import com.rs2.game.content.StaticNpcList.FROG_2470 +import com.rs2.game.content.StaticNpcList.FROG_2471 +import com.rs2.game.content.StaticNpcList.FROG_PRINCE +import com.rs2.game.content.StaticNpcList.FROG_PRINCESS +import com.rs2.game.npcs.NpcHandler +import com.rs2.game.players.Player +import com.rs2.util.Misc + +@SubscribesTo(NpcFirstClickEvent::class) +class FrogPlugin : EventSubscriber { + + companion object { + private val FROG_NPCS = intArrayOf(FROG_2469, FROG_2470, FROG_2471) + + fun startEvent(player: Player): Boolean { + if (player.inWild()) return false + val state = RandomEventSupport.state(player) + if (state.frogNpcSlots.any { RandomEventSupport.isNpcActive(player, it) }) { + return false + } + state.frogNpcSlots.clear() + val royalFrogId = if (player.playerAppearance[0] == 1) FROG_PRINCE else FROG_PRINCESS + val (royalX, royalY) = RandomEventSupport.findSpawnTile(player) + val royal = NpcHandler.spawnNpcReturn( + player, + royalFrogId, + royalX, + royalY, + player.heightLevel, + 0, + 0, + 0, + 0, + 0, + false, + false + ) ?: return false + royal.forceChat("Ribbit! Please help me, ${player.playerName}!") + state.frogNpcSlots.add(royal.npcId) + + for (frogId in FROG_NPCS) { + val (frogX, frogY) = RandomEventSupport.findSpawnTile(player) + val follower = NpcHandler.spawnNpcReturn( + player, + frogId, + frogX, + frogY, + player.heightLevel, + 0, + 0, + 0, + 0, + 0, + false, + false + ) + if (follower != null) { + state.frogNpcSlots.add(follower.npcId) + } + } + return true + } + + private fun despawnPlayerFrogs(player: Player) { + val state = RandomEventSupport.state(player) + for (slot in state.frogNpcSlots) { + RandomEventSupport.despawnNpcSlot(slot) + } + state.frogNpcSlots.clear() + } + } + + override fun test(event: NpcFirstClickEvent): Boolean { + return event.npc == FROG_PRINCE || event.npc == FROG_PRINCESS || event.npc in FROG_NPCS + } + + override fun subscribe(context: EventContext, player: Player, event: NpcFirstClickEvent) { + val state = RandomEventSupport.state(player) + if (state.frogNpcSlots.isNotEmpty() && !state.frogNpcSlots.contains(event.npcIndex)) { + player.packetSender.sendMessage("This frog isn't speaking to you.") + return + } + if (event.npc in FROG_NPCS) { + val dialogue = player.dialogueFactory + dialogue.clear() + dialogue.sendNpcChat(event.npc, "Ribbit! You should speak to our royal frog.") + .execute() + return + } + val title = if (event.npc == FROG_PRINCE) "frog prince" else "frog princess" + val dialogue = player.dialogueFactory + dialogue.clear() + dialogue.sendNpcChat(event.npc, "Ribbit! I am a $title under a spell. Please kiss me!") + .sendOption( + "Alright, I'll kiss you.", { + dialogue.clear() + dialogue.sendPlayerChat("Alright, here goes nothing...") + .onAction { + player.packetSender.closeAllWindows() + player.itemAssistant.addOrDropItem(FROG_TOKEN, 1) + player.packetSender.sendMessage("The frog gives you a frog token and hops away!") + despawnPlayerFrogs(player) + } + }, + "No way!", { + dialogue.clear() + dialogue.sendPlayerChat("No way! I'm not kissing a frog.") + .sendNpcChat(event.npc, "Very well... ribbit...") + .onAction { + player.packetSender.closeAllWindows() + despawnPlayerFrogs(player) + } + } + ) + .execute() + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/GenieLampButtonPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/GenieLampButtonPlugin.kt new file mode 100644 index 00000000..69c939ca --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/GenieLampButtonPlugin.kt @@ -0,0 +1,22 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ButtonActionEvent +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ButtonActionEvent::class) +class GenieLampButtonPlugin : EventSubscriber { + + override fun test(event: ButtonActionEvent) = LampInterfaceSupport.isLampButton(event.button) + + override fun subscribe(context: EventContext, player: Player, event: ButtonActionEvent) { + LampInterfaceSupport.handleLampButton( + player = player, + expectedItemId = GenieLampItemPlugin.GENIE_LAMP, + buttonId = event.button + ) { level -> level * 10 } + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/GenieLampItemPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/GenieLampItemPlugin.kt new file mode 100644 index 00000000..c933c73c --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/GenieLampItemPlugin.kt @@ -0,0 +1,23 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ItemFirstClickEvent +import com.rs2.game.content.StaticItemList.LAMP +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ItemFirstClickEvent::class) +class GenieLampItemPlugin : EventSubscriber { + + companion object { + const val GENIE_LAMP = LAMP + } + + override fun test(event: ItemFirstClickEvent) = event.item == GENIE_LAMP + + override fun subscribe(context: EventContext, player: Player, event: ItemFirstClickEvent) { + LampInterfaceSupport.openLampInterface(player, GENIE_LAMP, "You rub the lamp.") + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/GeniePlugin.kt b/2006Scape Server/plugins/game/content/randomevents/GeniePlugin.kt new file mode 100644 index 00000000..3b9eefb1 --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/GeniePlugin.kt @@ -0,0 +1,70 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.NpcFirstClickEvent +import com.rs2.game.content.StaticNpcList.GENIE +import com.rs2.game.npcs.NpcHandler +import com.rs2.game.players.Player + +@SubscribesTo(NpcFirstClickEvent::class) +class GeniePlugin : EventSubscriber { + + companion object { + private const val GENIE_LAMP = GenieLampItemPlugin.GENIE_LAMP + + fun titleFor(player: Player): String = if (player.playerAppearance[0] == 1) "Mistress" else "Master" + + fun spawn(player: Player): Boolean { + if (player.inWild()) return false + val state = RandomEventSupport.state(player) + if (RandomEventSupport.isNpcActive(player, state.genieNpcSlot)) { + return false + } + val (spawnX, spawnY) = RandomEventSupport.findSpawnTile(player) + val npc = NpcHandler.spawnNpcReturn( + player, + GENIE, + spawnX, + spawnY, + player.heightLevel, + 0, + 0, + 0, + 0, + 0, + false, + false + ) ?: return false + npc.forceChat("Greetings, ${titleFor(player)} ${player.playerName}!") + state.genieNpcSlot = npc.npcId + return true + } + } + + override fun test(event: NpcFirstClickEvent) = event.npc == GENIE + + override fun subscribe(context: EventContext, player: Player, event: NpcFirstClickEvent) { + val state = RandomEventSupport.state(player) + val clickedSlot = event.npcIndex + if (state.genieNpcSlot > 0 && clickedSlot != state.genieNpcSlot) { + player.packetSender.sendMessage("This genie is not here for you.") + return + } + val dialogue = player.dialogueFactory + dialogue.clear() + dialogue.sendNpcChat( + GENIE, + "Ah, so you are there, ${titleFor(player)} ${player.playerName}.", + "Please take this lamp, and make your wish!" + ) + .onAction { + player.packetSender.closeAllWindows() + player.itemAssistant.addOrDropItem(GENIE_LAMP, 1) + RandomEventSupport.despawnNpcSlot(clickedSlot) + state.genieNpcSlot = -1 + } + .execute() + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/RandomEventDispatcherPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/RandomEventDispatcherPlugin.kt new file mode 100644 index 00000000..d9633c93 --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/RandomEventDispatcherPlugin.kt @@ -0,0 +1,116 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.RandomActionEvent +import com.rs2.game.content.StaticItemList.MONKEY_GREEGREE +import com.rs2.game.players.Player +import com.rs2.util.Misc + +@SubscribesTo(RandomActionEvent::class) +class RandomEventDispatcherPlugin : EventSubscriber { + + override fun subscribe(context: EventContext, player: Player, event: RandomActionEvent) { + if (!player.randomEventsEnabled || + player.inFightCaves() || + player.tutorialProgress < 36 || + player.playerEquipment[player.playerWeapon] == MONKEY_GREEGREE + ) { + return + } + + val state = RandomEventSupport.state(player) + if (ZanarisChoirPlugin.isInZanaris(player) && Misc.random(80) == 1) { + ZanarisChoirPlugin.spawn(player) + } + when (event.source) { + "fishing" -> { + if (Misc.random(350) == 5 && CombatRandoms.spawnRiverTroll(player)) { + return + } + if (!RandomEventSupport.isNpcActive(player, state.riverTrollNpcSlot)) { + advanceGeneralRandom(player) + } + } + "woodcutting" -> { + if (Misc.random(350) == 69 && CombatRandoms.spawnTreeSpirit(player)) { + return + } + if (!RandomEventSupport.isNpcActive(player, state.treeSpiritNpcSlot)) { + advanceGeneralRandom(player) + } + } + "mining" -> { + if (Misc.random(350) == 42 && CombatRandoms.spawnRockGolem(player)) { + return + } + if (!RandomEventSupport.isNpcActive(player, state.rockGolemNpcSlot)) { + advanceGeneralRandom(player) + } + } + "prayer" -> { + if (Misc.random(300) == 4 && CombatRandoms.spawnZombie(player)) { + return + } + if (Misc.random(300) == 2 && CombatRandoms.spawnShade(player)) { + return + } + if (!RandomEventSupport.isNpcActive(player, state.zombieNpcSlot) && + !RandomEventSupport.isNpcActive(player, state.shadeNpcSlot) + ) { + advanceGeneralRandom(player) + } + } + else -> advanceGeneralRandom(player) + } + } + + private fun advanceGeneralRandom(player: Player) { + val state = RandomEventSupport.state(player) + val current = RandomEventSupport.getRandomActions(player) + if (current >= state.nextThreshold) { + triggerGeneralRandom(player) + if (player.playerIsBusy() && !SandwichLadyPlugin.isOpen(player)) { + player.packetSender.closeAllWindows() + } + } else { + if (player.playerRights == 3) { + val remaining = state.nextThreshold - current + player.packetSender.sendMessage("Next random will be in $remaining more random actions.") + } + RandomEventSupport.setRandomActions(player, current + 1) + } + } + + private fun triggerGeneralRandom(player: Player) { + when (Misc.random(5)) { + 0 -> { + if (SandwichLadyPlugin.spawn(player)) { + RandomEventSupport.resetRandomActions(player) + } + } + 1 -> { + CombatRandoms.spawnEvilChicken(player) + } + 2 -> { + FreakyForesterPlugin.teleportToLocation(player) + RandomEventSupport.resetRandomActions(player) + } + 3 -> { + CombatRandoms.spawnSwarm(player) + RandomEventSupport.resetRandomActions(player) + } + 4 -> { + if (GeniePlugin.spawn(player)) { + RandomEventSupport.resetRandomActions(player) + } + } + 5 -> { + if (FrogPlugin.startEvent(player)) { + RandomEventSupport.resetRandomActions(player) + } + } + } + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/RandomEventFollowPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/RandomEventFollowPlugin.kt new file mode 100644 index 00000000..6d1f8d15 --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/RandomEventFollowPlugin.kt @@ -0,0 +1,110 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.NpcTickSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.NpcTickEvent +import com.rs2.game.content.StaticNpcList.FROG_PRINCE +import com.rs2.game.content.StaticNpcList.FROG_PRINCESS +import com.rs2.game.content.StaticNpcList.GENIE +import com.rs2.game.content.StaticNpcList.SANDWICH_LADY +import com.rs2.game.content.StaticNpcList.ZANARIS_CHOIR +import com.rs2.game.npcs.Npc +import com.rs2.game.npcs.NpcHandler +import com.rs2.game.players.Player +import com.rs2.game.players.PlayerHandler +import com.rs2.util.Misc + +@SubscribesTo(NpcTickEvent::class) +class RandomEventFollowPlugin : EventSubscriber, NpcTickSubscriber { + + private val remainingTicks = IntArray(NpcHandler.npcs.size) + + companion object { + private const val CHOIR_DURATION_TICKS = 30 + private const val FOLLOW_DURATION_TICKS = 100 + private const val MAX_FOLLOW_DISTANCE = 16 + } + + override fun npcTypes() = intArrayOf(GENIE, SANDWICH_LADY, FROG_PRINCE, FROG_PRINCESS, ZANARIS_CHOIR) + + override fun test(event: NpcTickEvent): Boolean { + return event.npc.spawnedBy > 0 && event.npc.npcType in npcTypes() + } + + override fun subscribe(context: EventContext, player: Player?, event: NpcTickEvent) { + val index = event.index + val npc = event.npc + if (index <= 0 || index >= remainingTicks.size) return + + val owner = findOwner(npc) + if (owner == null || + owner.disconnected || + owner.heightLevel != npc.heightLevel || + owner.distanceToPoint(npc.absX, npc.absY) > MAX_FOLLOW_DISTANCE || + (npc.npcType == ZANARIS_CHOIR && !ZanarisChoirPlugin.isInZanaris(owner)) + ) { + despawn(index, npc, owner) + event.cancelTick() + return + } + + if (remainingTicks[index] <= 0) { + remainingTicks[index] = if (npc.npcType == ZANARIS_CHOIR) CHOIR_DURATION_TICKS else FOLLOW_DURATION_TICKS + } + remainingTicks[index]-- + if (remainingTicks[index] <= 0) { + despawn(index, npc, owner) + event.cancelTick() + return + } + + npc.facePlayer(owner) + NpcHandler.followPlayer(index, owner) + + if (npc.npcType == ZANARIS_CHOIR && remainingTicks[index] % 7 == 0) { + npc.forceChat(ZanarisChoirPlugin.randomLine()) + } else if (npc.npcType == GENIE && remainingTicks[index] % 20 == 0) { + npc.forceChat("Greetings, ${GeniePlugin.titleFor(owner)} ${owner.playerName}!") + } else if (npc.npcType == SANDWICH_LADY && remainingTicks[index] % 20 == 0) { + npc.forceChat("Allo ${owner.playerName}! Have a treat on me!") + } else if ((npc.npcType == FROG_PRINCE || npc.npcType == FROG_PRINCESS) && remainingTicks[index] % 20 == 0) { + npc.forceChat("Ribbit! Please help me, ${owner.playerName}!") + } + } + + private fun findOwner(npc: Npc): Player? { + for (p in PlayerHandler.players) { + if (p != null && p.id == npc.spawnedBy) { + return p + } + } + return null + } + + private fun despawn(index: Int, npc: Npc, owner: Player?) { + remainingTicks[index] = 0 + RandomEventSupport.despawnNpcSlot(index) + if (owner != null) { + val state = RandomEventSupport.state(owner) + when (npc.npcType) { + ZANARIS_CHOIR -> state.choirNpcSlot = -1 + GENIE -> state.genieNpcSlot = -1 + SANDWICH_LADY -> { + state.sandwichNpcSlot = -1 + state.hasSandwichLady = false + state.sandwichItemType = -1 + } + FROG_PRINCE, FROG_PRINCESS -> { + for (slot in state.frogNpcSlots) { + if (slot != index) { + RandomEventSupport.despawnNpcSlot(slot) + } + } + state.frogNpcSlots.clear() + } + } + } + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/RandomEventNpcDeathPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/RandomEventNpcDeathPlugin.kt new file mode 100644 index 00000000..3b0b6e1f --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/RandomEventNpcDeathPlugin.kt @@ -0,0 +1,25 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.NpcDeathEvent +import com.rs2.game.content.StaticNpcList.PHEASANT +import com.rs2.game.content.StaticNpcList.PHEASANT_2460 +import com.rs2.game.content.StaticNpcList.PHEASANT_2461 +import com.rs2.game.content.StaticNpcList.PHEASANT_2462 +import com.rs2.game.players.Player + +@SubscribesTo(NpcDeathEvent::class) +class RandomEventNpcDeathPlugin : EventSubscriber { + + override fun subscribe(context: EventContext, player: Player, event: NpcDeathEvent) { + CombatRandoms.onNpcDeath(player, event.npcType) + when (event.npcType) { + PHEASANT -> FreakyForesterPlugin.onPheasantKilled(player, 0) + PHEASANT_2460 -> FreakyForesterPlugin.onPheasantKilled(player, 1) + PHEASANT_2461 -> FreakyForesterPlugin.onPheasantKilled(player, 2) + PHEASANT_2462 -> FreakyForesterPlugin.onPheasantKilled(player, 3) + } + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/RandomEventSupport.kt b/2006Scape Server/plugins/game/content/randomevents/RandomEventSupport.kt new file mode 100644 index 00000000..8367bae0 --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/RandomEventSupport.kt @@ -0,0 +1,156 @@ +package plugin.game.content.randomevents + +import com.rs2.game.npcs.Npc +import com.rs2.game.npcs.NpcHandler +import com.rs2.game.players.Player +import com.rs2.util.Misc +import com.rs2.world.clip.Region +import java.util.Collections +import java.util.WeakHashMap + +object RandomEventSupport { + const val PLUGIN_ID = "randomevents" + const val RANDOM_ACTIONS_KEY = "randomActions" + const val FORESTER_REWARDED_KEY = "foresterRewarded" + + private const val BLOCKED_CLIP_MASK = 0x200000 or 0x40000 or 0x100 or 0x20000 or 0x80000 + + private val FAIL_COORDS = arrayOf( + intArrayOf(3333, 3333), + intArrayOf(3196, 3193), + intArrayOf(3084, 3549), + intArrayOf(2974, 3346), + intArrayOf(2781, 3506), + intArrayOf(2810, 3508) + ) + + private val ADJACENT_OFFSETS = arrayOf( + intArrayOf(0, 1), + intArrayOf(1, 0), + intArrayOf(0, -1), + intArrayOf(-1, 0), + intArrayOf(1, 1), + intArrayOf(-1, 1), + intArrayOf(1, -1), + intArrayOf(-1, -1) + ) + + class PlayerRandomState { + var nextThreshold: Int = 350 + Misc.random(100) + var sandwichItemType: Int = -1 + var hasSandwichLady: Boolean = false + var sandwichNpcSlot: Int = -1 + var chickenNpcSlot: Int = -1 + var riverTrollNpcSlot: Int = -1 + var rockGolemNpcSlot: Int = -1 + var treeSpiritNpcSlot: Int = -1 + var shadeNpcSlot: Int = -1 + var zombieNpcSlot: Int = -1 + var genieNpcSlot: Int = -1 + var choirNpcSlot: Int = -1 + var frogNpcSlots: MutableList = mutableListOf() + var foresterTargetPheasant: Int = -1 + var foresterKilledPheasant = BooleanArray(4) + var foresterCanLeave: Boolean = false + } + + private val sessionStates = Collections.synchronizedMap(WeakHashMap()) + + fun state(player: Player): PlayerRandomState { + return sessionStates.computeIfAbsent(player) { PlayerRandomState() } + } + + fun getRandomActions(player: Player): Int { + return player.pluginData.getInt(PLUGIN_ID, RANDOM_ACTIONS_KEY, 0) + } + + fun setRandomActions(player: Player, value: Int) { + player.pluginData.putInt(PLUGIN_ID, RANDOM_ACTIONS_KEY, value) + } + + fun resetRandomActions(player: Player) { + setRandomActions(player, 0) + state(player).nextThreshold = 350 + Misc.random(100) + } + + fun failEvent(player: Player) { + val coords = FAIL_COORDS[Misc.random(FAIL_COORDS.size - 1)] + player.teleportToX = coords[0] + player.teleportToY = coords[1] + player.heightLevel = 0 + player.packetSender.sendMessage("You wake up in a strange location...") + resetRandomActions(player) + player.packetSender.closeAllWindows() + } + + fun isNpcActive(player: Player, slot: Int): Boolean { + if (slot <= 0 || slot >= NpcHandler.npcs.size) return false + val npc = NpcHandler.npcs[slot] ?: return false + if (npc.isDead || npc.applyDead || npc.HP <= 0) return false + return npc.heightLevel == player.heightLevel && player.distanceToPoint(npc.absX, npc.absY) <= 16 + } + + fun findSpawnTile(player: Player): Pair { + val start = Misc.random(ADJACENT_OFFSETS.size - 1) + for (i in ADJACENT_OFFSETS.indices) { + val offset = ADJACENT_OFFSETS[(start + i) % ADJACENT_OFFSETS.size] + val x = player.absX + offset[0] + val y = player.absY + offset[1] + if ((Region.getClipping(x, y, player.heightLevel) and BLOCKED_CLIP_MASK) == 0) { + return x to y + } + } + return player.absX to player.absY + } + + data class CombatNpcTier( + val minCombat: Int, + val maxCombat: Int, + val npcId: Int, + val hitpoints: Int, + val maxHit: Int, + val attack: Int? = null, + val defence: Int? = null + ) + + fun spawnScaledCombatNpc( + player: Player, + tiers: List, + forceChat: String? = null, + attackOverride: ((Player, CombatNpcTier) -> Int)? = null, + defenceOverride: ((Player, CombatNpcTier) -> Int)? = null + ): Npc? { + val tier = tiers.firstOrNull { player.combatLevel in it.minCombat..it.maxCombat } ?: return null + val attack = attackOverride?.invoke(player, tier) ?: tier.attack ?: (tier.maxHit * 10) + val defence = defenceOverride?.invoke(player, tier) ?: tier.defence ?: (tier.maxHit * 10) + val (spawnX, spawnY) = findSpawnTile(player) + val npc = NpcHandler.spawnNpcReturn( + player, + tier.npcId, + spawnX, + spawnY, + player.heightLevel, + 0, + tier.hitpoints, + tier.maxHit, + attack, + defence, + true, + false + ) ?: return null + if (forceChat != null) { + npc.forceChat(forceChat) + } + return npc + } + + fun despawnNpcSlot(slot: Int) { + if (slot <= 0 || slot >= NpcHandler.npcs.size) return + val npc = NpcHandler.npcs[slot] ?: return + npc.absX = 0 + npc.absY = 0 + npc.isDead = true + npc.applyDead = true + NpcHandler.npcs[slot] = null + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/SandwichLadyPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/SandwichLadyPlugin.kt new file mode 100644 index 00000000..75013ffe --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/SandwichLadyPlugin.kt @@ -0,0 +1,113 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ButtonActionEvent +import com.rs2.game.content.StaticItemList.APPLE_PIE +import com.rs2.game.content.StaticItemList.BAGUETTE +import com.rs2.game.content.StaticItemList.BREAD +import com.rs2.game.content.StaticItemList.CHOCOLATE_BAR +import com.rs2.game.content.StaticItemList.KEBAB +import com.rs2.game.content.StaticItemList.SQUARE_SANDWICH +import com.rs2.game.content.StaticItemList.TRIANGLE_SANDWICH +import com.rs2.game.content.StaticNpcList.SANDWICH_LADY +import com.rs2.game.npcs.NpcHandler +import com.rs2.game.players.Player +import com.rs2.util.Misc + +@SubscribesTo(ButtonActionEvent::class) +class SandwichLadyPlugin : EventSubscriber { + + private data class SandwichOption( + val typeIndex: Int, + val buttonId: Int, + val itemId: Int, + val prompt: String + ) + + companion object { + private val OPTIONS = listOf( + SandwichOption(0, 63013, APPLE_PIE, "Please select the pie."), + SandwichOption(1, 63014, KEBAB, "Please select the kebab."), + SandwichOption(2, 63015, CHOCOLATE_BAR, "Please select the chocolate."), + SandwichOption(3, 63009, BAGUETTE, "Please select the baguette."), + SandwichOption(4, 63010, TRIANGLE_SANDWICH, "Please select the triangle sandwich."), + SandwichOption(5, 63011, SQUARE_SANDWICH, "Please select the square sandwich."), + SandwichOption(6, 63012, BREAD, "Please select the bread.") + ) + + fun spawn(player: Player): Boolean { + if (player.inWild()) return false + val state = RandomEventSupport.state(player) + if (RandomEventSupport.isNpcActive(player, state.sandwichNpcSlot)) { + return false + } + val (spawnX, spawnY) = RandomEventSupport.findSpawnTile(player) + val npc = NpcHandler.spawnNpcReturn( + player, + SANDWICH_LADY, + spawnX, + spawnY, + player.heightLevel, + 0, + 0, + 0, + 0, + 0, + false, + false + ) ?: return false + val chosen = OPTIONS[Misc.random(OPTIONS.size - 1)] + state.sandwichItemType = chosen.typeIndex + state.sandwichNpcSlot = npc.npcId + state.hasSandwichLady = false + npc.facePlayer(player) + npc.forceChat("Allo ${player.playerName}! Have a treat on me!") + return true + } + + fun openInterface(player: Player) { + val state = RandomEventSupport.state(player) + if (state.sandwichItemType !in OPTIONS.indices) { + state.sandwichItemType = OPTIONS[Misc.random(OPTIONS.size - 1)].typeIndex + } + val chosen = OPTIONS[state.sandwichItemType] + state.hasSandwichLady = true + player.packetSender.sendString(" ", 16131) + player.packetSender.sendString(chosen.prompt, 16145) + player.packetSender.showInterface(16135) + } + + fun isOpen(player: Player): Boolean = RandomEventSupport.state(player).hasSandwichLady + } + + override fun test(event: ButtonActionEvent): Boolean { + return event.button in 63009..63115 + } + + override fun subscribe(context: EventContext, player: Player, event: ButtonActionEvent) { + val state = RandomEventSupport.state(player) + if (!state.hasSandwichLady) { + if (state.sandwichNpcSlot <= 0) { + player.packetSender.sendMessage("You have improperly opened the sandwich lady interface.") + } + return + } + val option = OPTIONS.firstOrNull { it.buttonId == event.button } ?: return + if (state.sandwichItemType == option.typeIndex) { + player.packetSender.closeAllWindows() + player.itemAssistant.addOrDropItem(option.itemId, 1) + player.packetSender.sendMessage("Congratulations, you have completed the random event!") + } else { + player.packetSender.sendMessage("You have chosen the wrong item!") + RandomEventSupport.failEvent(player) + } + if (state.sandwichNpcSlot > 0) { + RandomEventSupport.despawnNpcSlot(state.sandwichNpcSlot) + state.sandwichNpcSlot = -1 + } + state.hasSandwichLady = false + state.sandwichItemType = -1 + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/SandwichLadyTalkPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/SandwichLadyTalkPlugin.kt new file mode 100644 index 00000000..5ebde092 --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/SandwichLadyTalkPlugin.kt @@ -0,0 +1,23 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.NpcFirstClickEvent +import com.rs2.game.content.StaticNpcList.SANDWICH_LADY +import com.rs2.game.players.Player + +@SubscribesTo(NpcFirstClickEvent::class) +class SandwichLadyTalkPlugin : EventSubscriber { + + override fun test(event: NpcFirstClickEvent) = event.npc == SANDWICH_LADY + + override fun subscribe(context: EventContext, player: Player, event: NpcFirstClickEvent) { + val state = RandomEventSupport.state(player) + if (state.sandwichNpcSlot > 0 && event.npcIndex != state.sandwichNpcSlot) { + player.packetSender.sendMessage("She is not here for you.") + return + } + SandwichLadyPlugin.openInterface(player) + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/ZanarisChoirPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/ZanarisChoirPlugin.kt new file mode 100644 index 00000000..1abda04b --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/ZanarisChoirPlugin.kt @@ -0,0 +1,49 @@ +package plugin.game.content.randomevents + +import com.rs2.game.content.StaticNpcList.ZANARIS_CHOIR +import com.rs2.game.npcs.NpcHandler +import com.rs2.game.players.Player +import com.rs2.util.Misc + +object ZanarisChoirPlugin { + private val CHOIR_LINES = arrayOf( + "Where are you going?", + "Can we come too?", + "La la la...", + "Do you always resort to violence so quickly?", + "If you should think of cutting a tree...", + "What a lovely day in Zanaris!" + ) + + fun isInZanaris(player: Player): Boolean { + return player.absX in 2368..2495 && player.absY in 4352..4479 + } + + fun randomLine(): String = CHOIR_LINES[Misc.random(CHOIR_LINES.size - 1)] + + fun spawn(player: Player): Boolean { + if (!isInZanaris(player)) return false + val state = RandomEventSupport.state(player) + if (RandomEventSupport.isNpcActive(player, state.choirNpcSlot)) { + return false + } + val (spawnX, spawnY) = RandomEventSupport.findSpawnTile(player) + val npc = NpcHandler.spawnNpcReturn( + player, + ZANARIS_CHOIR, + spawnX, + spawnY, + player.heightLevel, + 0, + 0, + 0, + 0, + 0, + false, + false + ) ?: return false + npc.forceChat(randomLine()) + state.choirNpcSlot = npc.npcId + return true + } +} diff --git a/2006Scape Server/plugins/game/content/randomevents/ZanarisChoirTalkPlugin.kt b/2006Scape Server/plugins/game/content/randomevents/ZanarisChoirTalkPlugin.kt new file mode 100644 index 00000000..c353baa6 --- /dev/null +++ b/2006Scape Server/plugins/game/content/randomevents/ZanarisChoirTalkPlugin.kt @@ -0,0 +1,22 @@ +package plugin.game.content.randomevents + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.NpcFirstClickEvent +import com.rs2.game.content.StaticNpcList.ZANARIS_CHOIR +import com.rs2.game.players.Player + +@SubscribesTo(NpcFirstClickEvent::class) +class ZanarisChoirTalkPlugin : EventSubscriber { + + override fun test(event: NpcFirstClickEvent) = event.npc == ZANARIS_CHOIR + + override fun subscribe(context: EventContext, player: Player, event: NpcFirstClickEvent) { + val dialogue = player.dialogueFactory + dialogue.clear() + dialogue.sendNpcChat(ZANARIS_CHOIR, "La la la! Where are you going? Can we come too?") + .sendPlayerChat("Er, I'm a bit busy right now...") + .execute() + } +} diff --git a/2006Scape Server/plugins/npc/thessalia/ThessaliaFirstClickPlugin.kt b/2006Scape Server/plugins/npc/thessalia/ThessaliaFirstClickPlugin.kt new file mode 100644 index 00000000..5d092277 --- /dev/null +++ b/2006Scape Server/plugins/npc/thessalia/ThessaliaFirstClickPlugin.kt @@ -0,0 +1,74 @@ +package plugin.npc.thessalia + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.NpcFirstClickEvent +import com.rs2.game.content.StaticItemList.FROG_MASK +import com.rs2.game.content.StaticItemList.FROG_TOKEN +import com.rs2.game.content.StaticItemList.PRINCE_LEGGINGS +import com.rs2.game.content.StaticItemList.PRINCE_TUNIC +import com.rs2.game.content.StaticItemList.PRINCESS_BLOUSE +import com.rs2.game.content.StaticItemList.PRINCESS_SKIRT +import com.rs2.game.content.StaticNpcList.THESSALIA +import com.rs2.game.players.Player +import com.rs2.util.Misc + +@SubscribesTo(NpcFirstClickEvent::class) +class ThessaliaFirstClickPlugin : EventSubscriber { + + override fun test(event: NpcFirstClickEvent) = event.npc == THESSALIA + + override fun subscribe(context: EventContext, player: Player, event: NpcFirstClickEvent) { + player.nextChat = 0 + player.dialogueAction = 0 + + val dialogue = player.dialogueFactory + dialogue.clear() + dialogue.sendNpcChat( + THESSALIA, + "Hello ${Misc.capitalize(player.playerName)}.", + "Are you interested in buying anything?" + ).sendOption( + "Yes please.", { + dialogue.clear() + dialogue.onAction { player.shopAssistant.openShop(12) } + }, + "No thanks.", { + dialogue.clear() + dialogue.sendPlayerChat("No thanks.") + }, + "I have a frog token I would like to exchange.", { + dialogue.clear() + dialogue.sendOption( + "A frog mask please!", { + dialogue.clear() + if (player.itemAssistant.playerHasItem(FROG_TOKEN, 1)) { + player.itemAssistant.deleteItem(FROG_TOKEN, 1) + player.itemAssistant.addOrDropItem(FROG_MASK, 1) + dialogue.sendPlayerChat("A frog mask please!") + } else { + dialogue.sendNpcChat(THESSALIA, "You don't have any frog tokens.") + } + }, + "A frog outfit, please!", { + dialogue.clear() + if (!player.itemAssistant.playerHasItem(FROG_TOKEN, 1)) { + dialogue.sendNpcChat(THESSALIA, "You don't have any frog tokens.") + } else if (player.playerAppearance[0] == 0) { + player.itemAssistant.deleteItem(FROG_TOKEN, 1) + player.itemAssistant.addOrDropItem(PRINCE_TUNIC, 1) + player.itemAssistant.addOrDropItem(PRINCE_LEGGINGS, 1) + dialogue.sendPlayerChat("A frog prince outfit, please!") + } else { + player.itemAssistant.deleteItem(FROG_TOKEN, 1) + player.itemAssistant.addOrDropItem(PRINCESS_BLOUSE, 1) + player.itemAssistant.addOrDropItem(PRINCESS_SKIRT, 1) + dialogue.sendPlayerChat("A frog princess outfit, please!") + } + } + ) + } + ).execute() + } +} diff --git a/2006Scape Server/plugins/npc/thessalia/ThessaliaSecondClickPlugin.kt b/2006Scape Server/plugins/npc/thessalia/ThessaliaSecondClickPlugin.kt new file mode 100644 index 00000000..28602a4d --- /dev/null +++ b/2006Scape Server/plugins/npc/thessalia/ThessaliaSecondClickPlugin.kt @@ -0,0 +1,18 @@ +package plugin.npc.thessalia + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.NpcSecondClickEvent +import com.rs2.game.content.StaticNpcList.THESSALIA +import com.rs2.game.players.Player + +@SubscribesTo(NpcSecondClickEvent::class) +class ThessaliaSecondClickPlugin : EventSubscriber { + + override fun test(event: NpcSecondClickEvent) = event.npc == THESSALIA + + override fun subscribe(context: EventContext, player: Player, event: NpcSecondClickEvent) { + player.shopAssistant.openShop(12) + } +} diff --git a/2006Scape Server/plugins/quests/atailoftwocats/TailOfTwoCatsLampButtonPlugin.kt b/2006Scape Server/plugins/quests/atailoftwocats/TailOfTwoCatsLampButtonPlugin.kt new file mode 100644 index 00000000..25b0bd5c --- /dev/null +++ b/2006Scape Server/plugins/quests/atailoftwocats/TailOfTwoCatsLampButtonPlugin.kt @@ -0,0 +1,24 @@ +package plugin.quests.atailoftwocats + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ButtonActionEvent +import com.rs2.game.content.StaticItemList.ANTIQUE_LAMP_6543 +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ButtonActionEvent::class) +class TailOfTwoCatsLampButtonPlugin : EventSubscriber { + + override fun test(event: ButtonActionEvent) = LampInterfaceSupport.isLampButton(event.button) + + override fun subscribe(context: EventContext, player: Player, event: ButtonActionEvent) { + LampInterfaceSupport.handleLampButton( + player = player, + expectedItemId = ANTIQUE_LAMP_6543, + buttonId = event.button, + minLevel = 30 + ) { 2_500 } + } +} diff --git a/2006Scape Server/plugins/quests/atailoftwocats/TailOfTwoCatsLampItemPlugin.kt b/2006Scape Server/plugins/quests/atailoftwocats/TailOfTwoCatsLampItemPlugin.kt new file mode 100644 index 00000000..6ae48888 --- /dev/null +++ b/2006Scape Server/plugins/quests/atailoftwocats/TailOfTwoCatsLampItemPlugin.kt @@ -0,0 +1,19 @@ +package plugin.quests.atailoftwocats + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ItemFirstClickEvent +import com.rs2.game.content.StaticItemList.ANTIQUE_LAMP_6543 +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ItemFirstClickEvent::class) +class TailOfTwoCatsLampItemPlugin : EventSubscriber { + + override fun test(event: ItemFirstClickEvent) = event.item == ANTIQUE_LAMP_6543 + + override fun subscribe(context: EventContext, player: Player, event: ItemFirstClickEvent) { + LampInterfaceSupport.openLampInterface(player, ANTIQUE_LAMP_6543, "You rub the antique lamp.") + } +} diff --git a/2006Scape Server/plugins/quests/onesmallfavour/OneSmallFavourLampButtonPlugin.kt b/2006Scape Server/plugins/quests/onesmallfavour/OneSmallFavourLampButtonPlugin.kt new file mode 100644 index 00000000..565afbf5 --- /dev/null +++ b/2006Scape Server/plugins/quests/onesmallfavour/OneSmallFavourLampButtonPlugin.kt @@ -0,0 +1,24 @@ +package plugin.quests.onesmallfavour + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ButtonActionEvent +import com.rs2.game.content.StaticItemList.ANTIQUE_LAMP +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ButtonActionEvent::class) +class OneSmallFavourLampButtonPlugin : EventSubscriber { + + override fun test(event: ButtonActionEvent) = LampInterfaceSupport.isLampButton(event.button) + + override fun subscribe(context: EventContext, player: Player, event: ButtonActionEvent) { + LampInterfaceSupport.handleLampButton( + player = player, + expectedItemId = ANTIQUE_LAMP, + buttonId = event.button, + minLevel = 30 + ) { 10_000 } + } +} diff --git a/2006Scape Server/plugins/quests/onesmallfavour/OneSmallFavourLampItemPlugin.kt b/2006Scape Server/plugins/quests/onesmallfavour/OneSmallFavourLampItemPlugin.kt new file mode 100644 index 00000000..0c610a96 --- /dev/null +++ b/2006Scape Server/plugins/quests/onesmallfavour/OneSmallFavourLampItemPlugin.kt @@ -0,0 +1,19 @@ +package plugin.quests.onesmallfavour + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ItemFirstClickEvent +import com.rs2.game.content.StaticItemList.ANTIQUE_LAMP +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ItemFirstClickEvent::class) +class OneSmallFavourLampItemPlugin : EventSubscriber { + + override fun test(event: ItemFirstClickEvent) = event.item == ANTIQUE_LAMP + + override fun subscribe(context: EventContext, player: Player, event: ItemFirstClickEvent) { + LampInterfaceSupport.openLampInterface(player, ANTIQUE_LAMP, "You rub the antique lamp.") + } +} diff --git a/2006Scape Server/plugins/quests/recipefordisaster/RecipeForDisasterLampButtonPlugin.kt b/2006Scape Server/plugins/quests/recipefordisaster/RecipeForDisasterLampButtonPlugin.kt new file mode 100644 index 00000000..78694ccd --- /dev/null +++ b/2006Scape Server/plugins/quests/recipefordisaster/RecipeForDisasterLampButtonPlugin.kt @@ -0,0 +1,24 @@ +package plugin.quests.recipefordisaster + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ButtonActionEvent +import com.rs2.game.content.StaticItemList.ANTIQUE_LAMP_7498 +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ButtonActionEvent::class) +class RecipeForDisasterLampButtonPlugin : EventSubscriber { + + override fun test(event: ButtonActionEvent) = LampInterfaceSupport.isLampButton(event.button) + + override fun subscribe(context: EventContext, player: Player, event: ButtonActionEvent) { + LampInterfaceSupport.handleLampButton( + player = player, + expectedItemId = ANTIQUE_LAMP_7498, + buttonId = event.button, + minLevel = 50 + ) { 20_000 } + } +} diff --git a/2006Scape Server/plugins/quests/recipefordisaster/RecipeForDisasterLampItemPlugin.kt b/2006Scape Server/plugins/quests/recipefordisaster/RecipeForDisasterLampItemPlugin.kt new file mode 100644 index 00000000..36163d23 --- /dev/null +++ b/2006Scape Server/plugins/quests/recipefordisaster/RecipeForDisasterLampItemPlugin.kt @@ -0,0 +1,19 @@ +package plugin.quests.recipefordisaster + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ItemFirstClickEvent +import com.rs2.game.content.StaticItemList.ANTIQUE_LAMP_7498 +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ItemFirstClickEvent::class) +class RecipeForDisasterLampItemPlugin : EventSubscriber { + + override fun test(event: ItemFirstClickEvent) = event.item == ANTIQUE_LAMP_7498 + + override fun subscribe(context: EventContext, player: Player, event: ItemFirstClickEvent) { + LampInterfaceSupport.openLampInterface(player, ANTIQUE_LAMP_7498, "You rub the antique lamp.") + } +} diff --git a/2006Scape Server/plugins/quests/shadowofthestorm/ShadowOfTheStormLampButtonPlugin.kt b/2006Scape Server/plugins/quests/shadowofthestorm/ShadowOfTheStormLampButtonPlugin.kt new file mode 100644 index 00000000..622fd109 --- /dev/null +++ b/2006Scape Server/plugins/quests/shadowofthestorm/ShadowOfTheStormLampButtonPlugin.kt @@ -0,0 +1,37 @@ +package plugin.quests.shadowofthestorm + +import com.rs2.Constants +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ButtonActionEvent +import com.rs2.game.content.StaticItemList.LAMP_6796 +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ButtonActionEvent::class) +class ShadowOfTheStormLampButtonPlugin : EventSubscriber { + + companion object { + private val COMBAT_SKILLS = setOf( + Constants.ATTACK, + Constants.DEFENCE, + Constants.STRENGTH, + Constants.HITPOINTS, + Constants.RANGED, + Constants.PRAYER, + Constants.MAGIC + ) + } + + override fun test(event: ButtonActionEvent) = LampInterfaceSupport.isLampButton(event.button) + + override fun subscribe(context: EventContext, player: Player, event: ButtonActionEvent) { + LampInterfaceSupport.handleLampButton( + player = player, + expectedItemId = LAMP_6796, + buttonId = event.button, + allowedSkills = COMBAT_SKILLS + ) { 10_000 } + } +} diff --git a/2006Scape Server/plugins/quests/shadowofthestorm/ShadowOfTheStormLampItemPlugin.kt b/2006Scape Server/plugins/quests/shadowofthestorm/ShadowOfTheStormLampItemPlugin.kt new file mode 100644 index 00000000..3b6b8dde --- /dev/null +++ b/2006Scape Server/plugins/quests/shadowofthestorm/ShadowOfTheStormLampItemPlugin.kt @@ -0,0 +1,19 @@ +package plugin.quests.shadowofthestorm + +import com.rs2.event.EventContext +import com.rs2.event.EventSubscriber +import com.rs2.event.SubscribesTo +import com.rs2.event.impl.ItemFirstClickEvent +import com.rs2.game.content.StaticItemList.LAMP_6796 +import com.rs2.game.players.Player +import plugin.game.content.items.lamps.LampInterfaceSupport + +@SubscribesTo(ItemFirstClickEvent::class) +class ShadowOfTheStormLampItemPlugin : EventSubscriber { + + override fun test(event: ItemFirstClickEvent) = event.item == LAMP_6796 + + override fun subscribe(context: EventContext, player: Player, event: ItemFirstClickEvent) { + LampInterfaceSupport.openLampInterface(player, LAMP_6796, "You rub the lamp.") + } +} diff --git a/2006Scape Server/pom.xml b/2006Scape Server/pom.xml index 1d0b9bd0..92bfe987 100644 --- a/2006Scape Server/pom.xml +++ b/2006Scape Server/pom.xml @@ -11,6 +11,8 @@ 1.6.10 + UTF-8 + UTF-8 diff --git a/2006Scape Server/src/main/java/com/rs2/event/impl/NpcDeathEvent.java b/2006Scape Server/src/main/java/com/rs2/event/impl/NpcDeathEvent.java new file mode 100644 index 00000000..373fcd68 --- /dev/null +++ b/2006Scape Server/src/main/java/com/rs2/event/impl/NpcDeathEvent.java @@ -0,0 +1,32 @@ +package com.rs2.event.impl; + +import com.rs2.event.Event; +import com.rs2.game.npcs.Npc; + +/** + * Event posted when an NPC dies and has an associated player killer or spawner. + */ +public final class NpcDeathEvent implements Event { + + private final int npcType; + private final int npcIndex; + private final Npc npc; + + public NpcDeathEvent(int npcType, int npcIndex, Npc npc) { + this.npcType = npcType; + this.npcIndex = npcIndex; + this.npc = npc; + } + + public int getNpcType() { + return npcType; + } + + public int getNpcIndex() { + return npcIndex; + } + + public Npc getNpc() { + return npc; + } +} diff --git a/2006Scape Server/src/main/java/com/rs2/event/impl/RandomActionEvent.java b/2006Scape Server/src/main/java/com/rs2/event/impl/RandomActionEvent.java new file mode 100644 index 00000000..fccfec74 --- /dev/null +++ b/2006Scape Server/src/main/java/com/rs2/event/impl/RandomActionEvent.java @@ -0,0 +1,20 @@ +package com.rs2.event.impl; + +import com.rs2.event.Event; + +/** + * Event posted when a player performs an action or skilling tick that may + * advance or trigger a random event. + */ +public final class RandomActionEvent implements Event { + + private final String source; + + public RandomActionEvent(String source) { + this.source = source; + } + + public String getSource() { + return source; + } +} diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/combat/magic/MagicTeleports.java b/2006Scape Server/src/main/java/com/rs2/game/content/combat/magic/MagicTeleports.java index 82b0e2f5..bdaf1013 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/combat/magic/MagicTeleports.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/combat/magic/MagicTeleports.java @@ -1,7 +1,7 @@ package com.rs2.game.content.combat.magic; import com.rs2.Constants; -import com.rs2.game.content.randomevents.RandomEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.players.Player; public class MagicTeleports { @@ -35,7 +35,7 @@ public class MagicTeleports { player.getPacketSender().sendMessage("You don't have the required runes to cast this spell."); return; } - RandomEventHandler.addRandom(player); + player.post(new RandomActionEvent("general")); CastRequirements.deleteRunes(player, teleport.getRequiredRunes()); player.getPlayerAssistant().startTeleport(teleport.getDestX(), teleport.getDestY(), teleport.getDestZ(), teleport.getType()); player.getPlayerAssistant().addSkillXP(teleport.getExperienceGained(), Constants.MAGIC); diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/music/Music.java b/2006Scape Server/src/main/java/com/rs2/game/content/music/Music.java index e4cf6355..270fe021 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/music/Music.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/music/Music.java @@ -10,127 +10,520 @@ import com.rs2.util.Misc; public class Music { - public static int[][] MUSIC_DATA = { // all the songs added - { 50, 51, 2 }, - { 49, 51, 2 }, // Flour mill place - { 48, 50, 3 }, - { 46, 56, 8 }, - // {51, 60, 9}, - { 46, 50, 12 }, - { 31, 74, 16 },// mime event - // {46, 50, 49}, - { 52, 57, 14 }, { 47, 52, 15 }, { 45, 53, 18 }, { 45, 54, 18 }, - { 47, 50, 35 }, - { 50, 150, 139 },// harmony 2 - { 46, 54, 23 },// goblin village - // {47, 50, 36}, - { 51, 50, 36 }, { 47, 51, 49 }, { 51, 49, 50 }, { 44, 75, 52 }, - { 46, 53, 54 }, { 49, 54, 111 }, { 51, 60, 255 }, // scape sad - { 45, 75, 57 }, { 47, 47, 62 },// Newbie Melody, Tutorial Island - // corrupted - { 47, 48, 62 },// Newbie Melody, Tutorial Island - { 48, 47, 62 },// Newbie Melody, Tutorial Island - { 48, 48, 62 },// Newbie Melody, Tutorial Island - { 48, 148, 144 },// underground, underground - { 49, 48, 62 },// Newbie Melody, Tutorial Island - { 50, 49, 64 }, { 49, 49, 64 }, { 46, 57, 355 }, // troubled - { 43, 75, 52 },// Miracle Dance, Mind Altar - // {51, 48, 69}, // this song is currently corrupt! Do not play! - // {46, 52, 107}, // falador different - { 46, 52, 72 }, // falador - { 50, 50, 76 }, { 48, 49, 358 }, // Vision - wizard's tower - { 46, 49, 92 },// karamja - { 45, 49, 92 },// karamja diff region - { 51, 54, 93 }, // Edgeville - { 46, 55, 96 }, // this song is currently corrupt! Do not play! - // -seems - // fine - // {45, 49, 55}, - { 46, 60, 52 }, { 48, 54, 98 }, { 47, 49, 105 }, // tommorrow - { 50, 52, 106 }, { 51, 51, 123 }, { 50, 53, 125 }, // Varrock But - // Laggyyyy - // {50, 53, 157}, //Varrock - { 46, 51, 127 }, { 48, 53, 141 }, { 41, 75, 52 },// Down to Earth, - // Earth Altar - { 42, 75, 52 },// Zealot, Water Altar - { 48, 51, 151 }, { 51, 52, 157 }, { 51, 53, 157 }, { 52, 50, 47 },// duel - // arena - { 52, 51, 122 }, // Duel Arena Hospital - Shine - { 41, 40, 588 }, // Pest Control - In-game - { 41, 41, 587 }, // Pest Control - Lobby - { 40, 75, 52 },// Quest, Fire Altar - { 55, 51, 380 },// Barrows - { 50, 55, 169 }, { 49, 154, 144 }, // varrock sewers repeated - { 50, 154, 144 }, // Varrock Sewers - { 48, 154, 144 }, // EdgeVille dungeon - { 48, 153, 144 }, // EdgeVilledungeon - { 48, 150, 144 },// draynor sewers - { 48, 151, 144 },// draynor sewers - { 43, 43, 206 }, // monkey madness - { 48, 55, 169 }, // Wilderness North of Edge - { 38, 80, 469 }, // Tzhaar cave - { 49, 57, 43 }, // wilderness 3 carrallanger - { 42, 53, 184 }, { 49, 53, 175 }, { 50, 54, 177 }, { 42, 43, 9 },// anywhere - { 43, 44, 9 },// anywhere again - { 45, 42, 190 },// marooneed - crash island - { 43, 42, 160 },// island life - works - { 44, 49, 172 },// jungle island - { 43, 50, 6 },// jolly r - { 43, 49, 174 },// landlubber - { 43, 50, 327 },// trawler - { 42, 50, 115 },// jungly2 - // {46, 49, 180}, - // {45, 52, 186}, ARRIVAL CORRUPTED - { 42, 54, 7 },// overture - { 54, 54, 357 }, // village canfis center 3496 3489 - // {0, 0, 282}, //Stillness myreque hideout - { 53, 54, 48 }, // morytania path to Paterdomus - { 54, 53, 347 }, // waterlogged south of canfis 3506, 3435 - { 45, 52, 72 }, { 40, 51, 191 },// knightly - { 41, 51, 32 },// baroque - { 40, 52, 152 }, // ballad of enchantment ardounge - { 47, 54, 152 }, // ballad of enchantment edgeville prayer 3051 3490 - { 39, 75, 52 },// Heart and Mind, Body Altar - { 47, 153, 325 },// Cave Background, Dwarven Mines - { 46, 153, 325 },// Cave Background, Dwarven Mines - { 47, 152, 325 },// Cave Background, Dwarven Mines - { 49, 50, 327 }, { 39, 47, 83 },// big chords - { 40, 48, 187 },// magic dance - { 39, 48, 187 },// magic dance watchtower not sure if correct song - { 45, 57, 185 }, // mad eadgar - doesn't play - // {40, 48, 153},//in the manor - { 47, 53, 49 }, // Wander - { 48, 52, 333 }, { 50, 56, 337 }, - // {40, 74, 419}, - { 47, 56, 121 }, { 39, 49, 148 }, // emotion 2524, 3168 - { 39, 50, 17 }, // attack1 2515, 3230 - { 39, 54, 32 }, // voyage 2528, 3497 - { 39, 54, 82 }, // waterfall 2511, 3463 - { 40, 54, 319 }, // theme coal trucks - { 38, 48, 80 }, // Soundscape, Castle Wars - { 37, 148, 28 }, // Attack 5 - Castle Wars, Sara Portal - { 43, 54, 60 }, // Lightwalk - Camelot - { 44, 53, 119 }, // fishing catherby - { 39, 54, 33 }, // gnome village coords = 2478, 3437 - { 38, 53, 329 }, // tree spirits - { 38, 54, 126 }, // Gnome King - { 37, 54, 130 }, // Gnome Ball plays a little bit out of region - // 2402, - // 3488 - { 40, 53, 328 }, // March - // {29, 81, 537},//Dogs of War - Stronghold of Security - Vault of - // War - // {31, 81, 558},//Food for Thought - Stronghold of Security - - // Catacomb - // of Famine - // {33, 82, 559},//Malady - Stronghold of Security - Pit of - // Pestilence - // {36, 81, 560},//Dance of Death - Stronghold of Security - - // Sepulchre - // of Death - { 41, 58, 141 }, // Relleka Rock Crabs - { 41, 53, 60 }, // Lasting - Range guild - { 41, 54, 140 } // Talking forest + public static int[][] MUSIC_DATA = { + { 0, 0, 282 }, // Chamber + { 27, 80, 573 }, // The Mad Mole + { 27, 81, 573 }, // The Mad Mole + { 28, 68, 198 }, // Dagannoth Dawn + { 29, 68, 524 }, // Xenophobe + { 29, 70, 470 }, // Strange Place + { 29, 72, 376 }, // Temple of Light + { 29, 75, 38 }, // Trawler + { 29, 83, 583 }, // Chef Surprise + { 30, 68, 198 }, // Dagannoth Dawn + { 30, 72, 375 }, // Fight or Flight + { 30, 73, 489 }, // Bubble and Squeak + { 30, 74, 413 }, // The Quizmaster + { 30, 75, 51 }, // Trawler Minor + { 30, 77, 434 }, // Have A Blast + { 30, 78, 324 }, // Background + { 31, 69, 532 }, // Diango's Little Helpers + { 31, 73, 271 }, // Well of Voyage + { 31, 74, 247 }, // Artistry + { 31, 75, 51 }, // Trawler Minor + { 31, 78, 244 }, // Waterlogged + { 32, 69, 511 }, // In the Clink + { 33, 48, 91 }, // Riverside + { 33, 49, 254 }, // Meridian + { 33, 50, 255 }, // Woodland + { 33, 51, 268 }, // Everywhere + { 33, 71, 1 }, // Iban + { 33, 72, 1 }, // Iban + { 33, 73, 1 }, // Iban + { 33, 75, 243 }, // Stratosphere + { 33, 78, 286 }, // Shadowland + { 33, 79, 497 }, // Aye Car Rum Ba + { 33, 80, 498 }, // Blistering Barnacles + { 34, 48, 270 }, // Exposed + { 34, 49, 254 }, // Meridian + { 34, 50, 255 }, // Woodland + { 34, 51, 268 }, // Everywhere + { 34, 75, 158 }, // Quest + { 34, 77, 269 }, // Competition + { 34, 78, 241 }, // Stagnant + { 35, 48, 253 }, // Lost Soul + { 35, 49, 251 }, // Forest + { 35, 50, 132 }, // Breeze + { 35, 51, 259 }, // Crystal Castle + { 35, 52, 259 }, // Crystal Castle + { 35, 73, 28 }, // Attack 5 + { 35, 74, 97 }, // Hermit + { 35, 75, 142 }, // Complication + { 35, 78, 245 }, // Natural + { 36, 47, 390 }, // Romper Chomper + { 36, 48, 253 }, // Lost Soul + { 36, 49, 372 }, // Far Away + { 36, 50, 252 }, // Elven Mist + { 36, 51, 256 }, // Overpass + { 36, 52, 130 }, // Tree Spirits + { 36, 53, 101 }, // Gnome Village 2 + { 36, 54, 112 }, // Gnomeball + { 36, 56, 544 }, // Making Waves + { 36, 57, 544 }, // Making Waves + { 36, 77, 373 }, // Claustrophobia + { 36, 78, 84 }, // Dead Quiet + { 36, 149, 271 }, // Well of Voyage + { 36, 150, 271 }, // Well of Voyage + { 36, 153, 95 }, // Intrepid + { 36, 154, 95 }, // Intrepid + { 37, 48, 314 }, // Castlewars + { 37, 49, 110 }, // Serenade + { 37, 50, 41 }, // Expecting + { 37, 51, 10 }, // Moody + { 37, 52, 130 }, // Tree Spirits + { 37, 53, 101 }, // Gnome Village 2 + { 37, 54, 112 }, // Gnomeball + { 37, 55, 112 }, // Gnomeball + { 37, 68, 118 }, // Faerie + { 37, 69, 118 }, // Faerie + { 37, 73, 30 }, // Voodoo Cult + { 37, 75, 131 }, // Understanding + { 37, 78, 84 }, // Dead Quiet + { 37, 79, 473 }, // TzHaar! + { 37, 80, 463 }, // Fire and Brimstone + { 37, 147, 153 }, // Expedition + { 37, 148, 28 }, // Attack 5 + { 37, 149, 323 }, // Underground Pass + { 37, 150, 323 }, // Underground Pass + { 37, 151, 59 }, // Cursed + { 37, 154, 296 }, // Technology + { 38, 46, 80 }, // Soundscape + { 38, 47, 392 }, // Zogre Dance + { 38, 48, 80 }, // Soundscape + { 38, 49, 110 }, // Serenade + { 38, 50, 41 }, // Expecting + { 38, 51, 10 }, // Moody + { 38, 52, 155 }, // Neverland + { 38, 53, 33 }, // Gnome Village + { 38, 54, 22 }, // Gnome King + { 38, 55, 22 }, // Gnome King + { 38, 68, 575 }, // Chickened Out + { 38, 69, 118 }, // Faerie + { 38, 74, 409 }, // Frogland + { 38, 75, 262 }, // Righteousness + { 38, 77, 425 }, // The Chosen + { 38, 80, 469 }, // In the Pits + { 38, 82, 603 }, // Funny Bunnies + { 38, 146, 394 }, // Wayward + { 38, 147, 394 }, // Wayward + { 38, 150, 41 }, // Expecting + { 38, 151, 59 }, // Cursed + { 38, 154, 348 }, // Narnode's Theme + { 38, 158, 448 }, // The Monsters Below + { 39, 46, 80 }, // Soundscape + { 39, 47, 159 }, // Gaol + { 39, 48, 83 }, // Big Chords + { 39, 49, 148 }, // Emotion + { 39, 50, 24 }, // Attack 1 + { 39, 51, 5 }, // Sad Meadow + { 39, 52, 328 }, // March + { 39, 53, 82 }, // Waterfall + { 39, 54, 32 }, // Voyage + { 39, 55, 66 }, // Legion + { 39, 56, 320 }, // Lighthouse + { 39, 58, 461 }, // The Desolate Isle + { 39, 60, 284 }, // Miscellania + { 39, 71, 129 }, // Spooky Jungle + { 39, 72, 322 }, // Out of the Deep + { 39, 73, 13 }, // Mage Arena + { 39, 74, 411 }, // Evil Bob's Island + { 39, 75, 190 }, // Heart and Mind + { 39, 77, 370 }, // In Between + { 39, 147, 159 }, // Gaol + { 39, 149, 148 }, // Emotion + { 39, 150, 331 }, // Scape Sad + { 39, 151, 478 }, // The Cellar Dwellers + { 39, 152, 133 }, // The Tower + { 39, 153, 82 }, // Waterfall + { 39, 154, 109 }, // Theme + { 39, 155, 66 }, // Legion + { 39, 156, 322 }, // Out of the Deep + { 39, 158, 517 }, // Subterranea + { 40, 46, 128 }, // Grumpy + { 40, 47, 188 }, // In the Manor + { 40, 48, 185 }, // Magic Dance + { 40, 49, 27 }, // Attack 4 + { 40, 50, 152 }, // Ballad Of Enchantment + { 40, 51, 191 }, // Knightly + { 40, 52, 133 }, // The Tower + { 40, 53, 193 }, // Mellow + { 40, 54, 109 }, // Theme + { 40, 56, 290 }, // Saga + { 40, 57, 289 }, // Rellekka + { 40, 58, 289 }, // Rellekka + { 40, 60, 285 }, // Etceteria + { 40, 69, 148 }, // Emotion + { 40, 70, 296 }, // Technology + { 40, 71, 308 }, // Suspicious + { 40, 74, 419 }, // Pheasant Peasant + { 40, 75, 158 }, // Quest + { 40, 147, 29 }, // Attack 6 + { 40, 148, 68 }, // Cavern + { 40, 149, 27 }, // Attack 4 + { 40, 150, 102 }, // Alone + { 40, 151, 478 }, // The Cellar Dwellers + { 40, 153, 346 }, // Goblin Game + { 40, 154, 109 }, // Theme + { 41, 40, 588 }, // Pest Control + { 41, 41, 587 }, // Null and Void + { 41, 46, 71 }, // Chompy Hunt + { 41, 48, 161 }, // Long Ago + { 41, 49, 167 }, // Fanfare 3 + { 41, 50, 70 }, // Upcoming + { 41, 51, 99 }, // Baroque + { 41, 52, 81 }, // Wonderous + { 41, 53, 60 }, // Lasting + { 41, 54, 140 }, // Talking Forest + { 41, 55, 20 }, // Lullaby + { 41, 56, 290 }, // Saga + { 41, 57, 289 }, // Rellekka + { 41, 58, 289 }, // Rellekka + { 41, 73, 107 }, // Miles Away + { 41, 75, 143 }, // Down To Earth + { 41, 79, 393 }, // Path of Peril + { 41, 81, 568 }, // Storm Brew + { 41, 146, 71 }, // Chompy Hunt + { 41, 148, 363 }, // 7th Realm + { 41, 149, 363 }, // 7th Realm + { 41, 150, 481 }, // Catch me if you can + { 41, 151, 169 }, // Crystal Sword + { 41, 152, 63 }, // Chain Of Command + { 41, 153, 63 }, // Chain Of Command + { 41, 154, 63 }, // Chain Of Command + { 41, 156, 316 }, // The Navigator + { 41, 157, 295 }, // Warrior + { 42, 42, 306 }, // Island Life + { 42, 43, 9 }, // Kingdom + { 42, 49, 164 }, // Landlubber + { 42, 50, 115 }, // Jungly 2 + { 42, 51, 91 }, // Riverside + { 42, 52, 192 }, // Trinity + { 42, 53, 184 }, // Magical Journey + { 42, 54, 7 }, // Overture + { 42, 55, 21 }, // Monarch Waltz + { 42, 56, 293 }, // Legend + { 42, 57, 291 }, // Borderland + { 42, 58, 291 }, // Borderland + { 42, 59, 291 }, // Borderland + { 42, 69, 282 }, // Chamber + { 42, 70, 278 }, // Deep Down + { 42, 71, 278 }, // Deep Down + { 42, 75, 146 }, // Zealot + { 42, 76, 378 }, // Forgotten + { 42, 79, 393 }, // Path of Peril + { 42, 142, 312 }, // Find My Way + { 42, 143, 311 }, // Showdown + { 42, 147, 362 }, // Karamja Jam + { 42, 148, 362 }, // Karamja Jam + { 42, 149, 364 }, // Pathways + { 42, 151, 17 }, // Escape + { 42, 152, 192 }, // Trinity + { 42, 153, 28 }, // Attack 5 + { 42, 154, 88 }, // Twilight + { 42, 156, 340 }, // Masquerade + { 43, 42, 160 }, // Army Of Darkness + { 43, 43, 303 }, // Monkey Madness + { 43, 44, 9 }, // Kingdom + { 43, 45, 129 }, // Spooky Jungle + { 43, 46, 114 }, // Jungly 1 + { 43, 47, 117 }, // Jungly 3 + { 43, 48, 58 }, // Nomad + { 43, 49, 55 }, // High Seas + { 43, 50, 6 }, // Jolly-R + { 43, 51, 119 }, // Fishing + { 43, 52, 324 }, // Background + { 43, 53, 74 }, // Lightwalk + { 43, 54, 104 }, // Camelot + { 43, 55, 104 }, // Camelot + { 43, 56, 293 }, // Legend + { 43, 57, 356 }, // Settlement + { 43, 58, 4 }, // Hells Bells + { 43, 60, 335 }, // Romancing the Crone + { 43, 69, 277 }, // Haunted Mine + { 43, 70, 282 }, // Chamber + { 43, 73, 148 }, // Emotion + { 43, 75, 65 }, // Miracle Dance + { 43, 77, 378 }, // Forgotten + { 43, 143, 307 }, // Temple + { 43, 145, 265 }, // Superstition + { 43, 146, 114 }, // Jungly 1 + { 43, 149, 248 }, // Aztec + { 43, 153, 19 }, // Arabique + { 43, 156, 341 }, // The Slayer + { 43, 157, 357 }, // Cave of Beasts + { 43, 158, 261 }, // Marzipan + { 44, 45, 172 }, // Jungle Island + { 44, 46, 90 }, // Ambient Jungle + { 44, 47, 165 }, // Tribal + { 44, 48, 162 }, // Tribal Background + { 44, 49, 172 }, // Jungle Island + { 44, 50, 170 }, // The Shadow + { 44, 51, 170 }, // The Shadow + { 44, 52, 324 }, // Background + { 44, 53, 119 }, // Fishing + { 44, 54, 87 }, // Ice Melody + { 44, 55, 9 }, // Kingdom + { 44, 56, 187 }, // Tremble + { 44, 57, 257 }, // Sojourn + { 44, 58, 292 }, // Stranded + { 44, 59, 294 }, // Frostbite + { 44, 71, 504 }, // Fangs for the Memory + { 44, 75, 52 }, // Serene + { 44, 79, 491 }, // Rat Hunt + { 44, 148, 162 }, // Tribal Background + { 44, 149, 336 }, // Dangerous Road + { 44, 150, 25 }, // Attack 2 + { 44, 152, 179 }, // Underground + { 44, 153, 19 }, // Arabique + { 44, 154, 100 }, // Beyond + { 44, 155, 100 }, // Beyond + { 44, 157, 261 }, // Marzipan + { 44, 158, 369 }, // Time to Mine + { 44, 159, 396 }, // Land of the Dwarves + { 45, 42, 190 }, // Heart and Mind + { 45, 45, 78 }, // Reggae + { 45, 46, 94 }, // Tribal 2 + { 45, 47, 89 }, // Reggae 2 + { 45, 48, 479 }, // Jungle Troubles + { 45, 49, 92 }, // Sea Shanty + { 45, 50, 138 }, // Emperor + { 45, 51, 107 }, // Miles Away + { 45, 52, 186 }, // Arrival + { 45, 53, 18 }, // Horizon + { 45, 54, 77 }, // Splendour + { 45, 55, 149 }, // Principality + { 45, 56, 258 }, // Contest + { 45, 57, 257 }, // Sojourn + { 45, 58, 292 }, // Stranded + { 45, 69, 524 }, // Xenophobe + { 45, 71, 242 }, // Time Out + { 45, 73, 83 }, // Big Chords + { 45, 75, 57 }, // Rune Essence + { 45, 79, 482 }, // Rat a Tat Tat + { 45, 145, 100 }, // Beyond + { 45, 146, 103 }, // Oriental + { 45, 148, 129 }, // Spooky Jungle + { 45, 150, 138 }, // Emperor + { 45, 151, 53 }, // Royale + { 45, 152, 173 }, // Dunjun + { 45, 153, 178 }, // Courage + { 45, 154, 178 }, // Courage + { 45, 156, 153 }, // Expedition + { 45, 157, 264 }, // Mad Eadgar + { 45, 158, 395 }, // Tale of Keldagrim + { 45, 159, 395 }, // Tale of Keldagrim + { 46, 45, 78 }, // Reggae + { 46, 46, 94 }, // Tribal 2 + { 46, 47, 166 }, // Fanfare 2 + { 46, 48, 515 }, // Mudskipper Melody + { 46, 49, 180 }, // Attention + { 46, 50, 12 }, // Long Way Home + { 46, 51, 127 }, // Nightfall + { 46, 52, 72 }, // Fanfare + { 46, 53, 54 }, // Scape Soft + { 46, 54, 23 }, // Gnome + { 46, 55, 34 }, // Wonder + { 46, 56, 113 }, // Lightness + { 46, 57, 183 }, // Troubled + { 46, 58, 43 }, // Wilderness 3 + { 46, 59, 37 }, // Deep Wildy + { 46, 60, 5 }, // Sad Meadow + { 46, 61, 52 }, // Serene + { 46, 148, 576 }, // Davy Jones' Locker + { 46, 149, 108 }, // Starlight + { 46, 150, 490 }, // Sarim's Vermin + { 46, 152, 173 }, // Dunjun + { 46, 153, 325 }, // Cave Background + { 46, 161, 52 }, // Serene + { 47, 47, 62 }, // Newbie Melody + { 47, 48, 62 }, // Newbie Melody + { 47, 49, 105 }, // Tomorrow + { 47, 50, 35 }, // Sea Shanty 2 + { 47, 51, 49 }, // Wander + { 47, 52, 15 }, // Workshop + { 47, 53, 150 }, // Gnome Theme + { 47, 54, 102 }, // Alone + { 47, 55, 96 }, // Inspiration + { 47, 56, 160 }, // Army Of Darkness + { 47, 57, 66 }, // Legion + { 47, 58, 159 }, // Gaol + { 47, 59, 43 }, // Wilderness 3 + { 47, 60, 98 }, // Forever + { 47, 61, 334 }, // Pirates of Peril + { 47, 73, 505 }, // Pharaoh's Tomb + { 47, 75, 412 }, // Into the Abyss + { 47, 77, 402 }, // The Rogues Den + { 47, 79, 403 }, // The Far Side + { 47, 85, 304 }, // Marooned + { 47, 149, 529 }, // Woe of the Wyvern + { 47, 152, 325 }, // Cave Background + { 47, 153, 325 }, // Cave Background + { 47, 160, 26 }, // Attack 3 + { 47, 161, 68 }, // Cavern + { 48, 47, 62 }, // Newbie Melody + { 48, 48, 62 }, // Newbie Melody + { 48, 49, 85 }, // Vision + { 48, 50, 3 }, // Unknown Land + { 48, 51, 151 }, // Start + { 48, 52, 333 }, // Spooky + { 48, 53, 141 }, // Barbarianism + { 48, 54, 98 }, // Forever + { 48, 55, 182 }, // Dangerous + { 48, 56, 8 }, // Wildwood + { 48, 57, 176 }, // Undercurrent + { 48, 58, 435 }, // Wilderness + { 48, 59, 43 }, // Wilderness 3 + { 48, 60, 98 }, // Forever + { 48, 61, 13 }, // Mage Arena + { 48, 148, 144 }, // Scape Cave + { 48, 149, 85 }, // Vision + { 48, 150, 144 }, // Scape Cave + { 48, 151, 144 }, // Scape Cave + { 48, 152, 338 }, // Tiptoe + { 48, 153, 141 }, // Barbarianism + { 48, 154, 98 }, // Forever + { 48, 155, 98 }, // Forever + { 48, 156, 98 }, // Forever + { 49, 45, 352 }, // Scarab + { 49, 46, 263 }, // Bandit Camp + { 49, 47, 79 }, // The Desert + { 49, 48, 62 }, // Newbie Melody + { 49, 49, 64 }, // Book Of Spells + { 49, 50, 327 }, // Dream + { 49, 51, 163 }, // Flute Salad + { 49, 52, 116 }, // Greatness + { 49, 53, 175 }, // Spirit + { 49, 54, 56 }, // Doorways + { 49, 55, 113 }, // Lightness + { 49, 56, 10 }, // Moody + { 49, 57, 43 }, // Wilderness 3 + { 49, 58, 67 }, // Close Quarters + { 49, 59, 189 }, // Wolf Mountain + { 49, 60, 332 }, // Scape Wild + { 49, 61, 106 }, // Expanse + { 49, 75, 418 }, // Corporal Punishment + { 49, 149, 389 }, // Cave of the Goblins + { 49, 150, 343 }, // Monster Melee + { 49, 152, 528 }, // Victory is Mine + { 49, 153, 330 }, // Cellar Song + { 49, 154, 144 }, // Scape Cave + { 50, 43, 383 }, // City of the Dead + { 50, 46, 267 }, // Sunburn + { 50, 47, 79 }, // The Desert + { 50, 48, 124 }, // Arabian 3 + { 50, 49, 145 }, // Yesteryear + { 50, 50, 76 }, // Harmony + { 50, 51, 2 }, // Autumn Voyage + { 50, 52, 106 }, // Expanse + { 50, 53, 125 }, // Garden + { 50, 54, 177 }, // Adventure + { 50, 55, 169 }, // Crystal Sword + { 50, 56, 337 }, // Faithless + { 50, 57, 332 }, // Scape Wild + { 50, 58, 120 }, // Shining + { 50, 59, 189 }, // Wolf Mountain + { 50, 60, 332 }, // Scape Wild + { 50, 61, 127 }, // Nightfall + { 50, 145, 359 }, // Sarcophagus + { 50, 146, 266 }, // Bone Dry + { 50, 148, 397 }, // Tears of Guthix + { 50, 149, 181 }, // Crystal Cave + { 50, 150, 46 }, // Harmony 2 + { 50, 152, 125 }, // Garden + { 50, 153, 125 }, // Garden + { 50, 154, 144 }, // Scape Cave + { 51, 43, 383 }, // City of the Dead + { 51, 44, 387 }, // Sphinx + { 51, 46, 174 }, // Desert Voyage + { 51, 47, 174 }, // Desert Voyage + { 51, 48, 69 }, // Egypt + { 51, 49, 50 }, // Al Kharid + { 51, 50, 36 }, // Arabian + { 51, 51, 123 }, // Arabian 2 + { 51, 52, 111 }, // Still Night + { 51, 53, 157 }, // Medieval + { 51, 54, 93 }, // Parade + { 51, 55, 121 }, // Forbidden + { 51, 56, 337 }, // Faithless + { 51, 57, 326 }, // Dark + { 51, 58, 14 }, // Witching + { 51, 59, 182 }, // Dangerous + { 51, 60, 331 }, // Scape Sad + { 51, 61, 329 }, // Regal + { 51, 143, 388 }, // Mirage + { 51, 147, 168 }, // Lonesome + { 51, 150, 407 }, // The Lost Melody + { 51, 153, 594 }, // No Way Out + { 51, 154, 144 }, // Scape Cave + { 52, 44, 505 }, // Pharaoh's Tomb + { 52, 45, 267 }, // Sunburn + { 52, 46, 351 }, // Dynasty + { 52, 47, 174 }, // Desert Voyage + { 52, 48, 69 }, // Egypt + { 52, 49, 50 }, // Al Kharid + { 52, 50, 47 }, // Duel Arena + { 52, 51, 122 }, // Shine + { 52, 52, 75 }, // Venture + { 52, 53, 20 }, // Lullaby + { 52, 54, 93 }, // Parade + { 52, 55, 121 }, // Forbidden + { 52, 56, 179 }, // Underground + { 52, 57, 326 }, // Dark + { 52, 58, 14 }, // Witching + { 52, 59, 182 }, // Dangerous + { 52, 60, 331 }, // Scape Sad + { 52, 61, 586 }, // Everlasting Fire + { 52, 62, 160 }, // Army Of Darkness + { 52, 145, 464 }, // The Genie + { 52, 149, 462 }, // Spirits of the Elid + { 52, 151, 534 }, // Mind over Matter + { 52, 152, 45 }, // Venture 2 + { 52, 153, 45 }, // Venture 2 + { 53, 45, 447 }, // Over to Nardah + { 53, 46, 465 }, // Desert Heat + { 53, 48, 377 }, // The Golem + { 53, 49, 36 }, // Arabian + { 53, 50, 286 }, // Shadowland + { 53, 51, 154 }, // Bone Dance + { 53, 52, 245 }, // Natural + { 53, 53, 84 }, // Dead Quiet + { 53, 54, 48 }, // Morytania + { 53, 55, 339 }, // The Terrible Tower + { 53, 150, 11 }, // Spooky 2 + { 53, 152, 246 }, // Grotto + { 53, 154, 156 }, // Mausoleum + { 54, 48, 377 }, // The Golem + { 54, 49, 501 }, // Distant Land + { 54, 51, 286 }, // Shadowland + { 54, 52, 241 }, // Stagnant + { 54, 53, 244 }, // Waterlogged + { 54, 54, 61 }, // Village + { 54, 55, 344 }, // Fenkenstrain's Refrain + { 54, 148, 260 }, // Insect Queen + { 54, 151, 287 }, // Lair + { 54, 153, 319 }, // Stillness + { 54, 155, 342 }, // Body Parts + { 55, 51, 380 }, // Dance of the Undead + { 55, 54, 288 }, // Deadlands + { 55, 151, 381 }, // Dangerous Way + { 55, 154, 345 }, // Barking Mad + { 56, 54, 288 }, // Deadlands + { 56, 55, 353 }, // Shipwrecked + { 57, 46, 530 }, // In the Brine + { 57, 54, 355 }, // The Other Side + { 57, 154, 354 }, // Phasmatys + { 57, 155, 471 }, // Brew Hoo Hoo! + { 59, 55, 358 } // Dragontooth Island }; /** @@ -142,16 +535,14 @@ public class Music { public static void checkMusic(Player c) { for (int[] aMUSIC_DATA : MUSIC_DATA) { if (c.getX() / 64 == aMUSIC_DATA[0] - && c.getY() / 64 == aMUSIC_DATA[1]/* - * && player . getPlayList ( - * ) . auto - */) { + && c.getY() / 64 == aMUSIC_DATA[1]) { if (c.getTemporary("CURRENT_SONG") == null || (Integer) c.getTemporary("CURRENT_SONG") != aMUSIC_DATA[2]) { c.getPacketSender().sendMessage( "@gre@Play Music Has Music:@bla@ " + aMUSIC_DATA[0] + " : " + aMUSIC_DATA[1]); } + return; } } c.getPacketSender().sendMessage( @@ -166,43 +557,31 @@ public class Music { * the player. */ public static void playMusic(Player c) { + int regionX = c.getX() / 64; + int regionY = c.getY() / 64; for (int[] aMUSIC_DATA : MUSIC_DATA) { - if (c.getX() / 64 == aMUSIC_DATA[0] - && c.getY() / 64 == aMUSIC_DATA[1]/* - * && player . - * getPlayList ( ) . - * auto - */) { - if (c.getTemporary("CURRENT_SONG") == null - || (Integer) c.getTemporary("CURRENT_SONG") != aMUSIC_DATA[2]) { - c.getPlayList(); - if (c.getPlayList().auto) { - c.addTemporary("CURRENT_SONG", aMUSIC_DATA[2]); - c.getPacketSender().sendSong(aMUSIC_DATA[2]); - } + if (regionX == aMUSIC_DATA[0] && regionY == aMUSIC_DATA[1]) { + int songId = aMUSIC_DATA[2]; + if (regionX == 48 && regionY == 54) { int[] edgeVilleSongs = { 98, 111, 127, 157, 106 }; - int toPlay = Misc.random(4); - if (aMUSIC_DATA[0] == 48 && aMUSIC_DATA[1] == 54) { - aMUSIC_DATA[2] = edgeVilleSongs[toPlay]; - } + songId = edgeVilleSongs[Misc.random(edgeVilleSongs.length - 1)]; + } else if (regionX == 43 && regionY == 50) { int[] karamjaSongs = { 327, 6 }; - int songPlaying = Misc.random(1); - if (aMUSIC_DATA[0] == 43 && aMUSIC_DATA[1] == 50) { - aMUSIC_DATA[2] = karamjaSongs[songPlaying]; - } + songId = karamjaSongs[Misc.random(karamjaSongs.length - 1)]; + } else if (regionX == 39 && regionY == 54) { int[] waterfall = { 82, 32 }; - int songToPlay = Misc.random(1); - if (aMUSIC_DATA[0] == 39 && aMUSIC_DATA[1] == 54) { - aMUSIC_DATA[2] = waterfall[songToPlay]; - } - /* - * int[] battlefield = {148, 17}; int randomSong = - * Misc.random(1); if (aMUSIC_DATA[0] == 39 && - * aMUSIC_DATA[1] == 50) { aMUSIC_DATA[2] = - * battlefield[randomSong]; } - */ - c.getPlayList().playSong(aMUSIC_DATA[2]); + songId = waterfall[Misc.random(waterfall.length - 1)]; } + + Integer currentSong = (Integer) c.getTemporary("CURRENT_SONG"); + if (currentSong == null || currentSong != songId) { + if (c.getPlayList().auto) { + c.addTemporary("CURRENT_SONG", songId); + c.getPacketSender().sendSong(songId); + } + c.getPlayList().playSong(songId); + } + return; } } } diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/music/PlayList.java b/2006Scape Server/src/main/java/com/rs2/game/content/music/PlayList.java index 4b9da70b..03c4c7dc 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/music/PlayList.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/music/PlayList.java @@ -28,25 +28,97 @@ public class PlayList { private final int[] values = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - public boolean[] unlocked = { false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, - false, false, false, false, true, false, false, false, false, - false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false }; - - private final String[] names = { "Autumn Voyage", "Unknown Land", - "Long Way Home", "Witching", "Kingdom", "Medieval", "Harmony", - "Rune Essence", "Pheasant Peasant", "Workshop", "Horizon", "Dream", - "Garden", "Expanse", "Arabian 2", "Adventure", "Crystal Sword", - "Forever", "Barbarianism", "Arabian", "Al Kharid", "Fanfare", - "Arrival", "Start", "Sea Shanty 2", "Attention", "Tomorrow", - "Nightfall", "Newbie Melody", "Spirit", "Scape Soft", - "Inspiration", "Wildwood", "Wonder", "Iban", "Egypt", - "Dogs of War", "Food for Thought", "Malady", "Dance of Death", + private final String[] names = { + "Autumn Voyage", "Unknown Land", "Long Way Home", "Witching", "Kingdom", + "Medieval", "Harmony", "Rune Essence", "Pheasant Peasant", "Workshop", + "Horizon", "Dream", "Garden", "Expanse", "Arabian 2", + "Adventure", "Crystal Sword", "Forever", "Barbarianism", "Arabian", + "Al Kharid", "Fanfare", "Arrival", "Start", "Sea Shanty 2", + "Attention", "Tomorrow", "Nightfall", "Newbie Melody", "Spirit", + "Scape Soft", "Inspiration", "Wildwood", "Wonder", "Iban", + "Egypt", "Dogs of War", "Food for Thought", "Malady", "Dance of Death", "Parade", "Down To Earth", "Faithless", "Book Of Spells", "Vision", - "Miracle Dance", "Quest", "Heart and Mind", "Cave Background", - "Talking Forest" }; + "Miracle Dance", "Quest", "Heart and Mind", "Cave Background", "Talking Forest", + "Jolly-R", "Overture", "Attack 1", "Attack 5", "Baroque", + "Gnome Village", "Wilderness 3", "Duel Arena", "Morytania", "Wander", + "Lightwalk", "Soundscape", "Waterfall", "Big Chords", "Jungly 2", + "Fishing", "Shine", "Gnome King", "Gnomeball", "Harmony 2", + "Underground", "Emotion", "Ballad Of Enchantment", "In the Manor", "Island Life", + "Jungle Island", "Landlubber", "Mad Eadgar", "Magic Dance", "Marooned", + "Knightly", "Monkey Madness", "Scape Sad", "Stillness", "Theme", + "March", "Tree Spirits", "Waterlogged", "Troubled", "Village", + "TzHaar!", "Faerie", "Scape Main", "Scape Original", "Scape Santa", + "Scape Scared", "7th Realm", "Alone", "Ambient Jungle", "Anywhere", + "Arabian 3", "Arabique", "Army Of Darkness", "Artistry", "Attack 2", + "Attack 3", "Attack 4", "Attack 6", "Aye Car Rum Ba", "Aztec", + "Background", "Bandit Camp", "Barking Mad", "Beyond", "Blistering Barnacles", + "Body Parts", "Bone Dance", "Bone Dry", "Borderland", "Breeze", + "Brew Hoo Hoo!", "Bubble and Squeak", "Cabin Fever", "Camelot", "Castlewars", + "Catch me if you can", "Cave of Beasts", "Cave of the Goblins", "Cavern", "Cellar Song", + "Chain Of Command", "Chamber", "Chef Surprise", "Chickened Out", "Chompy Hunt", + "City of the Dead", "Claustrophobia", "Close Quarters", "Competition", "Complication", + "Contest", "Corporal Punishment", "Courage", "Crystal Castle", "Crystal Cave", + "Cursed", "Dagannoth Dawn", "Dance of the Undead", "Dangerous", "Dangerous Road", + "Dangerous Way", "Dark", "Davy Jones' Locker", "Dead Can Dance", "Dead Quiet", + "Deadlands", "Deep Down", "Deep Wildy", "Desert Heat", "Desert Voyage", + "Diango's Little Helpers", "Distant Land", "Doorways", "Down Below", "Dragontooth Island", + "Dunjun", "Dynasty", "Elven Mist", "Emperor", "Escape", + "Etceteria", "Everlasting Fire", "Everywhere", "Evil Bob's Island", "Expecting", + "Expedition", "Exposed", "Fanfare 2", "Fanfare 3", "Fangs for the Memory", + "Far Away", "Fear and Loathing", "Fenkenstrain's Refrain", "Fight or Flight", "Find My Way", + "Fire and Brimstone", "Flute Salad", "Forbidden", "Forest", "Forgettable Melody", + "Forgotten", "Frogland", "Frostbite", "Fruits de Mer", "Funny Bunnies", + "Gaol", "Gnome", "Gnome Theme", "Gnome Village 2", "Goblin Game", + "Golden Touch", "Greatness", "Grip of the Talon", "Grotto", "Ground Scape", + "Grumpy", "Haunted Mine", "Have A Blast", "Hells Bells", "Hermit", + "High Seas", "Hypnotized", "Ice Melody", "In Between", "In the Brine", + "In the Clink", "In the Pits", "Incantation", "Insect Queen", "Into the Abyss", + "Intrepid", "Jungle Troubles", "Jungly 1", "Jungly 3", "Karamja Jam", + "La Mort", "Lair", "Lament", "Land of the Dwarves", "Last Stand", + "Lasting", "Legend", "Legion", "Lighthouse", "Lightness", + "Lonesome", "Long Ago", "Lost Soul", "Lullaby", "Mage Arena", + "Magical Journey", "Making Waves", "Marzipan", "Masquerade", "Mastermindless", + "Mausoleum", "Mellow", "Melodrama", "Meridian", "Method of Madness", + "Miles Away", "Mind over Matter", "Mirage", "Miscellania", "Monarch Waltz", + "Monster Melee", "Moody", "Mudskipper Melody", "Narnode's Theme", "Natural", + "Neverland", "No Way Out", "Nomad", "Null and Void", "Oriental", + "Out of the Deep", "Over to Nardah", "Overpass", "Path of Peril", "Pathways", + "Pest Control", "Pharaoh's Tomb", "Phasmatys", "Pirates of Peril", "Principality", + "Rat a Tat Tat", "Rat Hunt", "Ready for Battle", "Regal", "Reggae", + "Reggae 2", "Rellekka", "Right on Track", "Righteousness", "Riverside", + "Roll the Bones", "Romancing the Crone", "Romper Chomper", "Royale", "Sad Meadow", + "Saga", "Sarcophagus", "Sarim's Vermin", "Scape Cave", "Scape Wild", + "Scarab", "Sea Shanty", "Serenade", "Serene", "Settlement", + "Shadowland", "Shining", "Shipwrecked", "Showdown", "Sojourn", + "Sphinx", "Spirits of the Elid", "Splendour", "Spooky", "Spooky 2", + "Spooky Jungle", "Stagnant", "Starlight", "Still Night", "Storm Brew", + "Stranded", "Strange Place", "Stratosphere", "Subterranea", "Sunburn", + "Superstition", "Suspicious", "Tale of Keldagrim", "Tears of Guthix", "Technology", + "Temple", "Temple of Light", "The Cellar Dwellers", "The Chosen", "The Desert", + "The Desolate Isle", "The Enchanter", "The Far Side", "The Genie", "The Golem", + "The Lost Melody", "The Lost Tribe", "The Mad Mole", "The Monsters Below", "The Navigator", + "The Noble Rodent", "The Other Side", "The Power of Tears", "The Quizmaster", "The Rogues Den", + "The Shadow", "The Slayer", "The Terrible Tower", "The Tower", "Throne of the Demon", + "Time Out", "Time to Mine", "Tiptoe", "Title Fight", "Too Many Cooks...", + "Trawler", "Trawler Minor", "Tremble", "Tribal", "Tribal 2", + "Tribal Background", "Trinity", "Twilight", "Undercurrent", "Underground Pass", + "Understanding", "Upcoming", "Venture", "Venture 2", "Victory is Mine", + "Voodoo Cult", "Voyage", "Warrior", "Wayward", "Well of Voyage", + "Wild Side", "Wilderness", "Wilderness 2", "Woe of the Wyvern", "Wolf Mountain", + "Wonderous", "Woodland", "Wrath and Ruin", "Xenophobe", "Yesteryear", + "Zealot", "Zogre Dance" + }; + + public boolean[] unlocked = new boolean[names.length]; + { + unlocked[28] = true; // Newbie Melody + unlocked[92] = true; // Scape Main + unlocked[93] = true; // Scape Original + unlocked[94] = true; // Scape Santa + unlocked[95] = true; // Scape Scared + unlocked[204] = true; // Ground Scape + unlocked[316] = true; // Strange Place + } private boolean loop = false; @@ -57,41 +129,397 @@ public class PlayList { } private static enum Songs { - // action id, songid, ?, song number - AUTUMN_VOYAGE(16208, 2, 4304, 0), UNKNOWN_LAND(17066, 3, 4418, 1), LONG_WAY_HOME( - 17010, 12, 4362, 2), WITCHING(17078, 14, 4430, 3), KINGDOM( - 32243, 9, 8435, 4), MEDIEVAL(17016, 157, 4368, 5), HARMONY( - 16248, 76, 4344, 6), RUNE_ESSENCE(17034, 57, 4386, 7), PHEASANT_PEASANT( - 55108, 419, 14188, 8), WORKSHOP(17081, 15, 4433, 9), HORIZON( - 16250, 18, 4346, 10), DREAM(35014, 327, 8974, 11), GARDEN( - 16240, 125, 4336, 12), EXPANSE(16230, 106, 4326, 13), ARABIAN_2( - 16196, 123, 4292, 14), ADVENTURE(16191, 177, 4287, 15), CRYSTAL_SWORD( - 16220, 169, 4316, 16), FOREVER(16238, 98, 4334, 17), BARBARIANISM( - 19000, 141, 4864, 18), ARABIAN(16195, 36, 4291, 19), AL_KHARID( - 16192, 50, 4288, 20), FANFARE(16233, 72, 4329, 21), ARRIVAL( - 16200, 186, 4296, 22), - // START(151, 23, 2097152, 23), - SEA_SHANTY_2(17041, 35, 4393, 24), ATTENTION(16207, 180, 4303, 25), TOMORROW( - 24153, 105, 6297, 26), NIGHTFALL(17024, 127, 4376, 27), NEWBIE_MELODY( - 17023, 62, 4375, 28), SPIRIT(17046, 175, 4398, 29), SCAPE_SOFT( - 23100, 54, 5988, 30), INSPIRATION(16253, 96, 4349, 31), WILDWOOD( - 27071, 278, 6983, 32), WONDER(17079, 34, 4431, 33), IBAN(16251, - 1, 4347, 34), EGYPT(16228, 69, 4324, 35), PARADE(17027, 93, - 4379, 40), DOWN_TO_EARTH(19015, 143, 4879, 41), FAITHLESS( - 39145, 337, 346, 42), BOOK_OF_SPELLS(16214, 64, 4310, 43), VISION( - 17070, 85, 4422, 44), MIRACLE_DANCE(17019, 65, 4371, 45), QUEST( - 17028, 158, 4380, 46), HEART_AND_MIND(27033, 52, 6945, 47), // was - // 190 - // changed - // to - // 52 - CAVE_BACKGROUND(35012, 325, 8972, 48), TALKING_FOREST(17083, 140, 4435, - 49); + // action id, songid, child id, song number + AUTUMN_VOYAGE(16208, 2, 4304, 0, 20, 17), + UNKNOWN_LAND(17066, 3, 4418, 1, 24, 5), + LONG_WAY_HOME(17010, 12, 4362, 2, 22, 12), + WITCHING(17078, 14, 4430, 3, 24, 17), + KINGDOM(32243, 9, 8435, 4, 25, 30), + MEDIEVAL(17016, 157, 4368, 5, 22, 18), + HARMONY(16248, 76, 4344, 6, 21, 26), + RUNE_ESSENCE(17034, 57, 4386, 7, 23, 4), + PHEASANT_PEASANT(55108, 419, 14188, 8, 464, 1), + WORKSHOP(17081, 15, 4433, 9, 24, 20), + HORIZON(16250, 18, 4346, 10, 21, 28), + DREAM(35014, 327, 8974, 11, 21, 3), + GARDEN(16240, 125, 4336, 12, 21, 18), + EXPANSE(16230, 106, 4326, 13, 21, 8), + ARABIAN_2(16196, 123, 4292, 14, 20, 5), + ADVENTURE(16191, 177, 4287, 15, 20, 0), + CRYSTAL_SWORD(16220, 169, 4316, 16, 20, 29), + FOREVER(16238, 98, 4334, 17, 21, 16), + BARBARIANISM(19000, 141, 4864, 18, 346, 1), + ARABIAN(16195, 36, 4291, 19, 20, 4), + AL_KHARID(16192, 50, 4288, 20, 20, 1), + FANFARE(16233, 72, 4329, 21, 21, 12), + ARRIVAL(16200, 186, 4296, 22, 20, 9), + START(17082, 151, 4434, 23, 23, 21), + SEA_SHANTY_2(17041, 35, 4393, 24, 23, 11), + ATTENTION(16207, 180, 4303, 25, 20, 16), + TOMORROW(24153, 105, 6297, 26, 25, 3), + NIGHTFALL(17024, 127, 4376, 27, 22, 26), + NEWBIE_MELODY(17023, 62, 4375, 28, -1, 0), + SPIRIT(17046, 175, 4398, 29, 23, 16), + SCAPE_SOFT(23100, 54, 5988, 30, 24, 31), + INSPIRATION(16253, 96, 4349, 31, 21, 31), + WILDWOOD(27071, 8, 6983, 32, 346, 0), + WONDER(17079, 34, 4431, 33, 24, 18), + IBAN(16251, 1, 4347, 34, 21, 29), + EGYPT(16228, 69, 4324, 35, 21, 5), + PARADE(17027, 93, 4379, 40, 22, 29), + DOWN_TO_EARTH(19015, 143, 4879, 41, 346, 3), + FAITHLESS(39145, 337, 10129, 42, 346, 9), + BOOK_OF_SPELLS(16214, 64, 4310, 43, 20, 23), + VISION(17070, 85, 4422, 44, 24, 9), + MIRACLE_DANCE(17019, 65, 4371, 45, 22, 21), + QUEST(17028, 158, 4380, 46, 22, 30), + HEART_AND_MIND(27033, 190, 6945, 47, 25, 14), + CAVE_BACKGROUND(35012, 325, 8972, 48, 20, 25), + TALKING_FOREST(17083, 140, 4435, 49, 23, 23), + JOLLY_R(16255, 6, 4351, 50, 22, 1), + OVERTURE(17026, 7, 4378, 51, 22, 28), + ATTACK_1(16201, 24, 4297, 52, 20, 10), + ATTACK_5(16205, 28, 4301, 53, 20, 14), + BAROQUE(16211, 99, 4307, 54, 20, 20), + GNOME_VILLAGE(16243, 33, 4339, 55, 21, 21), + WILDERNESS_3(17076, 43, 4428, 56, 24, 16), + DUEL_ARENA(24154, 47, 6298, 57, 25, 4), + MORYTANIA(31181, 48, 8117, 58, 25, 20), + WANDER(17073, 49, 4425, 59, 24, 12), + LIGHTWALK(17008, 74, 4360, 60, 22, 10), + SOUNDSCAPE(17045, 80, 4397, 61, 23, 15), + WATERFALL(17074, 82, 4426, 62, 24, 13), + BIG_CHORDS(16213, 83, 4309, 63, 20, 22), + JUNGLY_2(17002, 115, 4354, 64, 22, 4), + FISHING(16236, 119, 4332, 65, 21, 14), + SHINE(17044, 122, 4396, 66, 23, 14), + GNOME_KING(16241, 22, 4337, 67, 21, 19), + GNOMEBALL(16246, 112, 4342, 68, 21, 24), + HARMONY_2(26187, 46, 6843, 69, 25, 7), + UNDERGROUND(17063, 179, 4415, 70, 24, 4), + EMOTION(16229, 148, 4325, 71, 21, 6), + BALLAD_OF_ENCHANTMENT(16210, 152, 4306, 72, 20, 19), + IN_THE_MANOR(16252, 188, 4348, 73, 21, 30), + ISLAND_LIFE(43130, 306, 11138, 74, 311, 18), + JUNGLE_ISLAND(17000, 172, 4352, 75, 22, 2), + LANDLUBBER(7091, 164, 1883, 76, 25, 9), + MAD_EADGAR(189, 264, 189, 77, 298, 21), + MAGIC_DANCE(17014, 185, 4366, 78, 22, 15), + MAROONED(43129, 304, 11137, 79, 311, 17), + KNIGHTLY(17004, 191, 4356, 80, 22, 6), + MONKEY_MADNESS(43128, 303, 11136, 81, 311, 15), + SCAPE_SAD(35017, 331, 8977, 82, 23, 8), + STILLNESS(46130, 319, 11906, 83, 311, 26), + THEME(17084, 109, 4436, 84, 23, 27), + MARCH(35015, 328, 8975, 85, 22, 17), + TREE_SPIRITS(17057, 130, 4409, 86, 23, 30), + WATERLOGGED(31204, 244, 8140, 87, 298, 7), + TROUBLED(17062, 183, 4414, 88, 24, 3), + VILLAGE(31182, 61, 8118, 89, 25, 22), + TZHAAR(23125, 473, 6013, 90, 464, 19), + FAERIE(16232, 118, 4328, 91, 21, 11), + SCAPE_MAIN(17037, 0, 4389, 92, -1, 0), + SCAPE_ORIGINAL(50040, 400, 12840, 93, -1, 0), + SCAPE_SANTA(46104, 547, 11880, 94, -1, 0), + SCAPE_SCARED(39142, 321, 10126, 95, -1, 0), + TRACK_7TH_REALM(46165, 363, 11941, 96, 346, 29), + ALONE(16193, 102, 4289, 97, 20, 2), + AMBIENT_JUNGLE(16194, 90, 4290, 98, 20, 3), + ANYWHERE(43126, 305, 11134, 99, 311, 16), + ARABIAN_3(16197, 124, 4293, 100, 20, 6), + ARABIQUE(16198, 19, 4294, 101, 20, 7), + ARMY_OF_DARKNESS(16199, 160, 4295, 102, 20, 8), + ARTISTRY(34231, 247, 8935, 103, 298, 8), + ATTACK_2(16202, 25, 4298, 104, 20, 11), + ATTACK_3(16203, 26, 4299, 105, 20, 12), + ATTACK_4(16204, 27, 4300, 106, 20, 13), + ATTACK_6(16206, 29, 4302, 107, 20, 15), + AYE_CAR_RUM_BA(58024, 497, 14872, 108, 464, 31), + AZTEC(2152, 248, 664, 109, 298, 9), + BACKGROUND(35011, 324, 8971, 110, 20, 18), + BANDIT_CAMP(29030, 263, 7454, 111, 298, 22), + BARKING_MAD(47096, 345, 12128, 112, 346, 18), + BEYOND(16212, 100, 4308, 113, 20, 21), + BLISTERING_BARNACLES(58023, 498, 14871, 114, 598, 0), + BODY_PARTS(47095, 342, 12127, 115, 346, 14), + BONE_DANCE(35008, 154, 8968, 116, 25, 23), + BONE_DRY(50044, 266, 12844, 117, 298, 24), + BORDERLAND(39127, 291, 10111, 118, 311, 9), + BREEZE(33117, 132, 8565, 119, 298, 2), + BREW_HOO_HOO(55162, 471, 14242, 120, 464, 18), + BUBBLE_AND_SQUEAK(60134, 489, 15494, 121, 464, 27), + CABIN_FEVER(68100, 545, 17508, 122, 598, 27), + CAMELOT(16215, 104, 4311, 123, 20, 24), + CASTLEWARS(44212, 314, 11476, 124, 311, 23), + CATCH_ME_IF_YOU_CAN(60133, 481, 15493, 125, 464, 24), + CAVE_OF_BEASTS(48102, 357, 12390, 126, 346, 24), + CAVE_OF_THE_GOBLINS(49040, 389, 12584, 127, 414, 16), + CAVERN(16217, 68, 4313, 128, 20, 26), + CELLAR_SONG(35020, 330, 8980, 129, 25, 13), + CHAIN_OF_COMMAND(16218, 63, 4314, 130, 20, 27), + CHAMBER(44220, 282, 11484, 131, 311, 1), + CHEF_SURPRISE(246, 583, 246, 132, 662, 15), + CHICKENED_OUT(71126, 575, 18302, 133, 662, 11), + CHOMPY_HUNT(2162, 71, 674, 134, 25, 18), + CITY_OF_THE_DEAD(50049, 383, 12849, 135, 414, 12), + CLAUSTROPHOBIA(50010, 373, 12810, 136, 414, 3), + CLOSE_QUARTERS(27032, 67, 6944, 137, 25, 15), + COMPETITION(42231, 269, 10983, 138, 298, 25), + COMPLICATION(19006, 142, 4870, 139, 346, 2), + CONTEST(32244, 258, 8436, 140, 298, 16), + CORPORAL_PUNISHMENT(24007, 418, 6151, 141, 464, 3), + COURAGE(19016, 178, 4880, 142, 346, 4), + CRYSTAL_CASTLE(33119, 259, 8567, 143, 298, 18), + CRYSTAL_CAVE(16219, 181, 4315, 144, 20, 28), + CURSED(2165, 59, 677, 145, 25, 26), + DAGANNOTH_DAWN(52073, 198, 13385, 146, 598, 13), + DANCE_OF_THE_UNDEAD(52040, 380, 13352, 147, 414, 10), + DANGEROUS(16221, 182, 4317, 148, 20, 30), + DANGEROUS_ROAD(39144, 336, 10128, 149, 346, 7), + DANGEROUS_WAY(52041, 381, 13353, 150, 414, 11), + DARK(35013, 326, 8973, 151, 20, 31), + DAVY_JONES_LOCKER(71099, 576, 18275, 152, 662, 10), + DEAD_CAN_DANCE(56117, 476, 14453, 153, 464, 21), + DEAD_QUIET(31206, 84, 8142, 154, 25, 21), + DEADLANDS(34232, 288, 8936, 155, 311, 6), + DEEP_DOWN(44219, 278, 11483, 156, 311, 0), + DEEP_WILDY(16223, 37, 4319, 157, 21, 0), + DESERT_HEAT(23108, 465, 5996, 158, 464, 13), + DESERT_VOYAGE(16224, 174, 4320, 159, 21, 1), + DIANGOS_LITTLE_HELPERS(61226, 532, 15842, 160, 598, 19), + DISTANT_LAND(12248, 501, 3320, 161, 598, 1), + DOORWAYS(16225, 56, 4321, 162, 21, 2), + DOWN_BELOW(50048, 361, 12848, 163, 346, 28), + DRAGONTOOTH_ISLAND(48001, 358, 12289, 164, 346, 25), + DUNJUN(16227, 173, 4323, 165, 21, 4), + DYNASTY(50035, 351, 12835, 166, 346, 19), + ELVEN_MIST(33127, 252, 8575, 167, 298, 10), + EMPEROR(17089, 138, 4441, 168, 21, 7), + ESCAPE(27031, 17, 6943, 169, 25, 16), + ETCETERIA(43100, 285, 11108, 170, 311, 3), + EVERLASTING_FIRE(73096, 586, 18784, 171, 721, 1), + EVERYWHERE(33124, 268, 8572, 172, 298, 27), + EVIL_BOBS_ISLAND(55163, 411, 14243, 173, 414, 28), + EXPECTING(16231, 41, 4327, 174, 21, 9), + EXPEDITION(17085, 153, 4437, 175, 21, 10), + EXPOSED(33120, 270, 8568, 176, 298, 28), + FANFARE_2(16234, 166, 4330, 177, 25, 2), + FANFARE_3(16235, 167, 4331, 178, 21, 13), + FANGS_FOR_THE_MEMORY(72084, 504, 18516, 179, 598, 2), + FAR_AWAY(27118, 372, 7030, 180, 414, 4), + FEAR_AND_LOATHING(58222, 602, 15070, 181, 662, 21), + FENKENSTRAINS_REFRAIN(47094, 344, 12126, 182, 346, 15), + FIGHT_OR_FLIGHT(27132, 375, 7044, 183, 414, 5), + FIND_MY_WAY(43134, 312, 11142, 184, 311, 22), + FIRE_AND_BRIMSTONE(10242, 463, 2802, 185, 464, 14), + FLUTE_SALAD(16237, 163, 4333, 186, 21, 15), + FORBIDDEN(2164, 121, 676, 187, 25, 25), + FOREST(33126, 251, 8574, 188, 298, 11), + FORGETTABLE_MELODY(55087, 436, 14167, 189, 464, 6), + FORGOTTEN(50042, 378, 12842, 190, 414, 8), + FROGLAND(55109, 409, 14189, 191, 464, 16), + FROSTBITE(50047, 294, 12847, 192, 311, 12), + FRUITS_DE_MER(43099, 347, 11107, 193, 346, 17), + FUNNY_BUNNIES(72253, 603, 18685, 194, 662, 22), + GAOL(16239, 159, 4335, 195, 21, 17), + GNOME(16245, 23, 4341, 196, 21, 23), + GNOME_THEME(16242, 150, 4338, 197, 21, 20), + GNOME_VILLAGE_2(16244, 101, 4340, 198, 21, 22), + GOBLIN_GAME(43098, 346, 11106, 199, 311, 28), + GOLDEN_TOUCH(62016, 535, 15888, 200, 598, 22), + GREATNESS(16247, 116, 4343, 201, 21, 25), + GRIP_OF_THE_TALON(59246, 520, 15350, 202, 598, 12), + GROTTO(31202, 246, 8138, 203, 298, 6), + GROUND_SCAPE(54148, 466, 13972, 204, -1, 0), + GRUMPY(2163, 128, 675, 205, 25, 17), + HAUNTED_MINE(44217, 277, 11481, 206, 298, 30), + HAVE_A_BLAST(57010, 434, 14602, 207, 464, 5), + HELLS_BELLS(46105, 4, 11881, 208, 311, 30), + HERMIT(32242, 97, 8434, 209, 25, 31), + HIGH_SEAS(16249, 55, 4345, 210, 21, 27), + HYPNOTIZED(17154, 384, 4506, 211, 414, 13), + ICE_MELODY(3193, 87, 961, 212, 25, 5), + IN_BETWEEN(50009, 370, 12809, 213, 414, 2), + IN_THE_BRINE(68101, 530, 17509, 214, 598, 18), + IN_THE_CLINK(63018, 511, 16146, 215, 598, 8), + IN_THE_PITS(10243, 469, 2803, 216, 464, 15), + INCANTATION(59251, 519, 15355, 217, 598, 11), + INSECT_QUEEN(6203, 260, 1739, 218, 298, 20), + INTO_THE_ABYSS(53144, 412, 13712, 219, 414, 29), + INTREPID(16254, 95, 4350, 220, 22, 0), + JUNGLE_TROUBLES(57011, 479, 14603, 221, 464, 23), + JUNGLY_1(17001, 114, 4353, 222, 22, 3), + JUNGLY_3(17003, 117, 4355, 223, 22, 5), + KARAMJA_JAM(46163, 362, 11939, 224, 346, 30), + LA_MORT(23138, 134, 6026, 225, 298, 0), + LAIR(35007, 287, 8967, 226, 311, 5), + LAMENT(63020, 542, 16148, 227, 598, 29), + LAND_OF_THE_DWARVES(53008, 396, 13576, 228, 414, 22), + LAST_STAND(247, 546, 247, 229, 598, 28), + LASTING(17005, 60, 4357, 230, 22, 7), + LEGEND(29028, 293, 7452, 231, 311, 11), + LEGION(17006, 66, 4358, 232, 22, 8), + LIGHTHOUSE(39147, 320, 10131, 233, 311, 27), + LIGHTNESS(17007, 113, 4359, 234, 22, 9), + LONESOME(24041, 168, 6185, 235, 24, 21), + LONG_AGO(17009, 161, 4361, 236, 22, 11), + LOST_SOUL(33121, 253, 8569, 237, 298, 12), + LULLABY(17012, 20, 4364, 238, 22, 13), + MAGE_ARENA(17013, 13, 4365, 239, 22, 14), + MAGICAL_JOURNEY(17015, 184, 4367, 240, 22, 16), + MAKING_WAVES(248, 544, 248, 241, 598, 26), + MARZIPAN(190, 261, 190, 242, 298, 19), + MASQUERADE(47015, 340, 12047, 243, 346, 12), + MASTERMINDLESS(71128, 577, 18304, 244, 662, 13), + MAUSOLEUM(31180, 156, 8116, 245, 25, 24), + MELLOW(17017, 193, 4369, 246, 22, 19), + MELODRAMA(44213, 317, 11477, 247, 311, 24), + MERIDIAN(33122, 254, 8570, 248, 298, 13), + METHOD_OF_MADNESS(58226, 600, 15074, 249, 662, 20), + MILES_AWAY(17018, 107, 4370, 250, 22, 20), + MIND_OVER_MATTER(62017, 534, 15889, 251, 598, 21), + MIRAGE(17155, 388, 4507, 252, 414, 15), + MISCELLANIA(43101, 284, 11109, 253, 311, 2), + MONARCH_WALTZ(17020, 21, 4372, 254, 22, 22), + MONSTER_MELEE(48048, 343, 12336, 255, 346, 16), + MOODY(17021, 10, 4373, 256, 22, 23), + MUDSKIPPER_MELODY(59189, 515, 15293, 257, 598, 9), + NARNODES_THEME(43125, 348, 11133, 258, 346, 18), + NATURAL(31203, 245, 8139, 259, 298, 5), + NEVERLAND(17022, 155, 4374, 260, 22, 24), + NO_WAY_OUT(58229, 594, 15077, 261, 662, 19), + NOMAD(7101, 58, 1893, 262, 25, 11), + NULL_AND_VOID(72034, 587, 18466, 263, 662, 16), + ORIENTAL(17025, 103, 4377, 264, 22, 27), + OUT_OF_THE_DEEP(39148, 322, 10132, 265, 311, 29), + OVER_TO_NARDAH(60230, 447, 15590, 266, 464, 8), + OVERPASS(33125, 256, 8573, 267, 298, 15), + PATH_OF_PERIL(50045, 393, 12845, 268, 414, 19), + PATHWAYS(46164, 364, 11940, 269, 346, 31), + PEST_CONTROL(73002, 588, 18690, 270, 662, 17), + PHARAOHS_TOMB(63019, 505, 16147, 271, 598, 3), + PHASMATYS(47255, 354, 12287, 272, 346, 21), + PIRATES_OF_PERIL(39143, 334, 10127, 273, 346, 6), + PRINCIPALITY(32241, 149, 8433, 274, 25, 28), + RAT_A_TAT_TAT(60136, 482, 15496, 275, 464, 25), + RAT_HUNT(60137, 491, 15497, 276, 464, 29), + READY_FOR_BATTLE(44214, 318, 11478, 277, 311, 25), + REGAL(35016, 329, 8976, 278, 22, 31), + REGGAE(17030, 78, 4382, 279, 23, 0), + REGGAE_2(17031, 89, 4383, 280, 23, 1), + RELLEKKA(39128, 289, 10112, 281, 311, 7), + RIGHT_ON_TRACK(55088, 44, 14168, 282, 464, 7), + RIGHTEOUSNESS(192, 262, 192, 283, 298, 31), + RIVERSIDE(17032, 91, 4384, 284, 23, 2), + ROLL_THE_BONES(62018, 533, 15890, 285, 598, 20), + ROMANCING_THE_CRONE(46106, 335, 11882, 286, 346, 8), + ROMPER_CHOMPER(52047, 390, 13359, 287, 414, 24), + ROYALE(17033, 53, 4385, 288, 23, 3), + SAD_MEADOW(17035, 5, 4387, 289, 23, 5), + SAGA(29027, 290, 7451, 290, 311, 8), + SARCOPHAGUS(50046, 359, 12846, 291, 346, 27), + SARIMS_VERMIN(60138, 490, 15498, 292, 464, 28), + SCAPE_CAVE(17036, 144, 4388, 293, 23, 6), + SCAPE_WILD(35018, 332, 8978, 294, 23, 9), + SCARAB(50050, 352, 12850, 295, 346, 26), + SEA_SHANTY(17040, 92, 4392, 296, 23, 10), + SERENADE(17042, 110, 4394, 297, 23, 12), + SERENE(17043, 52, 4395, 298, 23, 13), + SETTLEMENT(48103, 356, 12391, 299, 346, 23), + SHADOWLAND(35010, 286, 8970, 300, 311, 4), + SHINING(23102, 120, 5990, 301, 25, 0), + SHIPWRECKED(47254, 353, 12286, 302, 346, 20), + SHOWDOWN(43133, 311, 11141, 303, 311, 21), + SOJOURN(188, 257, 188, 304, 298, 17), + SPHINX(50051, 387, 12851, 305, 414, 14), + SPIRITS_OF_THE_ELID(60231, 462, 15591, 306, 464, 11), + SPLENDOUR(17047, 77, 4399, 307, 23, 17), + SPOOKY(35019, 333, 8979, 308, 23, 18), + SPOOKY_2(44218, 11, 11482, 309, 298, 26), + SPOOKY_JUNGLE(17049, 129, 4401, 310, 23, 19), + STAGNANT(31205, 241, 8141, 311, 298, 1), + STARLIGHT(17050, 108, 4402, 312, 23, 20), + STILL_NIGHT(17051, 111, 4403, 313, 23, 22), + STORM_BREW(68116, 568, 17524, 314, 662, 8), + STRANDED(46107, 292, 11883, 315, 311, 10), + STRANGE_PLACE(59130, 470, 15234, 316, 464, 17), + STRATOSPHERE(29036, 243, 7460, 317, 298, 3), + SUBTERRANEA(59076, 517, 15180, 318, 598, 10), + SUNBURN(29029, 267, 7453, 319, 298, 23), + SUPERSTITION(19017, 265, 4881, 320, 346, 5), + SUSPICIOUS(43132, 308, 11140, 321, 311, 20), + TALE_OF_KELDAGRIM(53007, 395, 13575, 322, 414, 21), + TEARS_OF_GUTHIX(12204, 397, 3276, 323, 414, 23), + TECHNOLOGY(43127, 296, 11135, 324, 311, 14), + TEMPLE(43131, 307, 11139, 325, 311, 19), + TEMPLE_OF_LIGHT(23137, 376, 6025, 326, 414, 6), + THE_CELLAR_DWELLERS(56119, 478, 14455, 327, 464, 22), + THE_CHOSEN(54076, 425, 13900, 328, 464, 4), + THE_DESERT(17052, 79, 4404, 329, 23, 24), + THE_DESOLATE_ISLE(43087, 461, 11095, 330, 464, 10), + THE_ENCHANTER(62015, 541, 15887, 331, 598, 24), + THE_FAR_SIDE(53212, 403, 13780, 332, 414, 26), + THE_GENIE(23109, 464, 5997, 333, 464, 12), + THE_GOLEM(50041, 377, 12841, 334, 414, 7), + THE_LOST_MELODY(52048, 407, 13360, 335, 414, 27), + THE_LOST_TRIBE(52049, 420, 13361, 336, 464, 2), + THE_MAD_MOLE(70255, 573, 18175, 337, 662, 9), + THE_MONSTERS_BELOW(55106, 448, 14186, 338, 464, 9), + THE_NAVIGATOR(39130, 316, 10114, 339, 311, 31), + THE_NOBLE_RODENT(60135, 485, 15495, 340, 464, 26), + THE_OTHER_SIDE(48000, 355, 12288, 341, 346, 22), + THE_POWER_OF_TEARS(12205, 398, 3277, 342, 414, 31), + THE_QUIZMASTER(55110, 413, 14190, 343, 414, 30), + THE_ROGUES_DEN(53211, 402, 13779, 344, 414, 25), + THE_SHADOW(17053, 170, 4405, 345, 23, 25), + THE_SLAYER(47017, 341, 12049, 346, 346, 13), + THE_TERRIBLE_TOWER(47016, 339, 12048, 347, 346, 11), + THE_TOWER(17054, 133, 4406, 348, 23, 26), + THRONE_OF_THE_DEMON(50043, 379, 12843, 349, 414, 9), + TIME_OUT(32240, 242, 8432, 350, 298, 4), + TIME_TO_MINE(50008, 369, 12808, 351, 414, 1), + TIPTOE(39149, 338, 10133, 352, 346, 10), + TITLE_FIGHT(61210, 525, 15826, 353, 598, 15), + TOO_MANY_COOKS(71129, 386, 18305, 354, 662, 14), + TRAWLER(17055, 38, 4407, 355, 23, 28), + TRAWLER_MINOR(17056, 51, 4408, 356, 23, 29), + TREMBLE(32245, 187, 8437, 357, 25, 29), + TRIBAL(17059, 165, 4411, 358, 24, 0), + TRIBAL_2(17060, 94, 4412, 359, 24, 1), + TRIBAL_BACKGROUND(17058, 162, 4410, 360, 23, 31), + TRINITY(17061, 192, 4413, 361, 24, 2), + TWILIGHT(29037, 88, 7461, 362, 25, 19), + UNDERCURRENT(7098, 176, 1890, 363, 25, 10), + UNDERGROUND_PASS(28214, 323, 7382, 364, 24, 6), + UNDERSTANDING(2166, 131, 678, 365, 25, 27), + UPCOMING(17068, 70, 4420, 366, 24, 7), + VENTURE(17069, 75, 4421, 367, 24, 8), + VENTURE_2(26211, 45, 6867, 368, 25, 8), + VICTORY_IS_MINE(61213, 528, 15829, 369, 598, 16), + VOODOO_CULT(17071, 30, 4423, 370, 24, 10), + VOYAGE(17072, 32, 4424, 371, 24, 11), + WARRIOR(39129, 295, 10113, 372, 311, 13), + WAYWARD(52042, 394, 13354, 373, 414, 20), + WELL_OF_VOYAGE(33118, 271, 8566, 374, 298, 29), + WILD_SIDE(56118, 475, 14454, 375, 464, 20), + WILDERNESS(53145, 435, 13713, 376, 24, 14), + WILDERNESS_2(17075, 42, 4427, 377, 24, 15), + WOE_OF_THE_WYVERN(61214, 529, 15830, 378, 598, 17), + WOLF_MOUNTAIN(26186, 189, 6842, 379, 25, 6), + WONDEROUS(17080, 81, 4432, 380, 24, 19), + WOODLAND(33123, 255, 8571, 381, 298, 14), + WRATH_AND_RUIN(58233, 565, 15081, 382, 662, 7), + XENOPHOBE(59242, 524, 15346, 383, 598, 14), + YESTERYEAR(23101, 145, 5989, 384, 25, 1), + ZEALOT(7106, 146, 1898, 385, 25, 12), + ZOGRE_DANCE(52043, 392, 13355, 386, 414, 18); private int songId; private int buttonId; private int childId; private int arraySlot; + private int varpId; + private int varpBit; public int songId() { return songId; @@ -99,12 +527,12 @@ public class PlayList { @SuppressWarnings("unused") public int configId() { - return songId; + return varpId; } @SuppressWarnings("unused") public int configNumber() { - return songId; + return varpBit; } @SuppressWarnings("unused") @@ -112,11 +540,13 @@ public class PlayList { return arraySlot; } - Songs(int buttonId, int songId, int childId, int arraySlot) { + Songs(int buttonId, int songId, int childId, int arraySlot, int varpId, int varpBit) { this.buttonId = buttonId; this.songId = songId; this.childId = childId; this.arraySlot = arraySlot; + this.varpId = varpId; + this.varpBit = varpBit; } private static Map songs = new HashMap(); @@ -132,22 +562,38 @@ public class PlayList { } - public void fixAllColors() { - for (int i = 0; i < 385; i++) { - if (Songs.get(i) != null) { - player.getPacketSender().sendColor(Songs.get(i).childId, - 255 << 10 | 0 << 5 | 0); - if (unlocked[Songs.get(i).arraySlot]) { - updateList(Songs.get(i).childId); - } + private static final int[] MUSIC_VARPS = { 20, 21, 22, 23, 24, 25, 298, 311, + 346, 414, 464, 598, 662, 721 }; + + private int getVarpMask(int varpId) { + int mask = 0; + for (Songs song : Songs.values()) { + if (song.varpId == varpId && unlocked[song.arraySlot]) { + mask |= (1 << song.varpBit); } } + return mask; + } + + private void sendMusicVarp(int varpId) { + if (varpId != -1) { + player.getPacketSender().sendConfig(varpId, getVarpMask(varpId)); + } + } + + public void sendMusicConfigs() { + for (int varpId : MUSIC_VARPS) { + player.getPacketSender().sendConfig(varpId, getVarpMask(varpId)); + } + player.getPacketSender().sendConfig(18, auto ? 1 : 0); + player.getPacketSender().sendConfig(19, loop ? 1 : 0); } public void playSong(int songID) { // System.out.println("songId = "+songID); try { - if (Songs.get(songID) == null) { + Songs song = Songs.get(songID); + if (song == null) { // player.sendMessage("This song has not yet been added to the playlist. - Song ID = "+songID); if (auto) { player.getPacketSender().sendString("Song Unavailable!", @@ -156,21 +602,19 @@ public class PlayList { } return; } - if (!unlocked[Songs.get(songID).arraySlot]) { + if (!unlocked[song.arraySlot]) { player.getPacketSender().sendMessage( "You have unlocked the song " - + names[Songs.get(songID).arraySlot] + "."); - // System.out.println("You have unlocked the song " + - // names[Songs.get(songID).arraySlot]); - unlocked[Songs.get(songID).arraySlot] = true; - updateList(Songs.get(songID).childId); + + names[song.arraySlot] + "."); + unlocked[song.arraySlot] = true; + sendMusicVarp(song.varpId); player.getPacketSender().sendString( - names[Songs.get(songID).arraySlot], 4439); + names[song.arraySlot], 4439); updateList(4439); } else { if (auto) { player.getPacketSender().sendString( - names[Songs.get(songID).arraySlot], 4439); + names[song.arraySlot], 4439); updateList(4439); } } @@ -180,41 +624,38 @@ public class PlayList { } public void updateList(int id) { - player.getPacketSender().sendColor(id, 0 << 10 | 255 << 5 | 0); + player.getPacketSender().sendColor(id, 0 << 10 | 31 << 5 | 0); } public void handleButton(int button) { - if (button == 17023) { - return; - } - if (button == 9925) { + if (button == 38197) { loop = !loop; - } else if (button == 6269) { + player.getPacketSender().sendConfig(19, loop ? 1 : 0); + } else if (button == 24125) { auto = true; player.getPacketSender().sendConfig(18, 1); - } else if (button == 6270) { + Music.playMusic(player); + } else if (button == 24126) { auto = false; player.getPacketSender().sendConfig(18, 0); } else { - // System.out.println("button="+button); int songId = -1; - for (int i = 0; i < 385; i++) { - if (Songs.get(i) != null) { - if (Songs.get(i).buttonId == button) { - songId = Songs.get(i).songId; - } + for (Songs song : Songs.values()) { + if (song.buttonId == button) { + songId = song.songId; + break; } } if (songId == -1) { - // player.getPacketDispatcher().sendMessage("That song is unavailable at this time."); + // Song not yet mapped in playlist } else if (!unlocked[Songs.get(songId).arraySlot]) { player.getPacketSender().sendMessage( "You have to unlock that song first!"); } else { auto = false; player.getPacketSender().sendConfig(18, 0); + player.addTemporary("CURRENT_SONG", songId); playSong(songId); - // System.out.println("sending music to ActionSender packet - song id = "+songId); player.getPacketSender().sendSong(songId); player.getPacketSender().sendString( names[Songs.get(songId).arraySlot], 4439); @@ -222,4 +663,4 @@ public class PlayList { } } } -} +} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/EvilChicken.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/EvilChicken.java deleted file mode 100644 index 2a4e8079..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/EvilChicken.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.game.npcs.NpcHandler; -import com.rs2.game.players.Player; -import com.rs2.util.Misc; - -public class EvilChicken { - - // min cmb, maxcmb, npcid, maxhit, attack, defence - private static int[][] chicken = { { 3, 10, 2463, 19, 1, 10, 10 }, - { 11, 20, 2464, 40, 1, 30, 30 }, { 21, 40, 2465, 60, 2, 60, 60 }, - { 41, 60, 2466, 80, 3, 80, 80 }, - { 61, 90, 2467, 105, 4, 100, 100 }, - { 91, 138, 2468, 120, 5, 120, 120 }, }; - - public static void spawnChicken(Player c) { - for (int[] aChicken : chicken) { - if (c.chickenSpawned == false) { - if (c.combatLevel >= aChicken[0] && c.combatLevel <= aChicken[1]) { - NpcHandler.spawnNpc(c, aChicken[2], c.absX + Misc.random(1), c.absY + Misc.random(1), c.heightLevel, 0, aChicken[3], aChicken[4], aChicken[5], aChicken[6], true, false); - c.chickenSpawned = true; - c.randomActions = 0; - } - } - } - } -} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/FreakyForester.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/FreakyForester.java deleted file mode 100644 index 98c87f43..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/FreakyForester.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.game.players.Player; -import com.rs2.util.Misc; - -public class FreakyForester { - - public static void teleportToLocation(Player c) { - c.lastX = c.absX; - c.lastY = c.absY; - c.lastH = c.heightLevel; - c.teleportToX = 2602; - c.teleportToY = 4775; - c.heightLevel = 0; - c.getPacketSender().sendMessage("Talk to the freaky forester to get out."); - } - - private static String[] pheasant = { "one", "two", "three", "four", }; - - public static String getPheasant(Player client) { - if (client.getPheasent < 0) { - client.getPheasent = Misc.random(3); - } - return pheasant[client.getPheasent] + " tailed"; - } - - public static void leaveArea(Player client) { - if (client.killedPheasant[client.getPheasent]) { - client.getPlayerAssistant().movePlayer(client.lastX, client.lastY, client.lastH); - client.canLeaveArea = true; - client.getPacketSender().sendMessage("Congratulations, you've completed the freaky forester event!"); - if (client.recievedReward == false) { - client.getItemAssistant().addItem(6180, 1); - client.getItemAssistant().addItem(6181, 1); - client.getItemAssistant().addItem(6182, 1); - client.recievedReward = true; - } else { - client.getItemAssistant().addItem(995, 500); - client.getPacketSender().sendMessage("You have already beat the freaky forester event so you get 500 coins."); - } - int delete = client.getItemAssistant().getItemAmount(6178); - client.getItemAssistant().deleteItem(6178, delete); - client.randomActions = 0; - } else { - RandomEventHandler.failEvent(client); - } - for (int i = 0; i < 4; i++) { - client.killedPheasant[i] = false; - } - client.getPheasent = -1; - client.canLeaveArea = false; - } - - public static void killedPheasant(Player c, int p) { - for (int i = 0; i < 4; i++) { - c.killedPheasant[i] = false; - } - c.killedPheasant[p] = true; - } - - public static boolean hasKilledPheasant(Player client) { - for (int i = 0; i < 4; i++) { - if (client.killedPheasant[i]) { - client.canLeaveArea = true; - return true; - } - } - client.canLeaveArea = false; - return false; - } -} diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Frog.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Frog.java deleted file mode 100644 index 48666744..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Frog.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.game.npcs.NpcHandler; -import com.rs2.game.players.Client; -import com.rs2.util.Misc; - -/** - * Frog Event - * @author Andrew (I'm A Boss on Rune-Server, Mr Extremez on Moparscape & Runelocus) - */ - -public final class Frog { - - private static final int[][] FROG_DATA = { { 2469, 2470, 2471, 2472, 2473 } }; - - public static void startEvent(Client client) { - spawnFrogs(client); - spawnBasedOnGender(client); - client.ignoreFrog = false; - } - - public static void finishEvent(Client client) {// breaks - if (client.ignoreFrog) { - client.getPlayerAssistant().movePlayer(client.lastX, client.lastY, client.lastH); - } - giveReward(client); - } - - public static void spawnBasedOnGender(Client client) {// ternary - NpcHandler.spawnNpc(client, client.playerAppearance[0] == 1 ? 2474 : 2475, client.absX + Misc.random(1), client.absY + Misc.random(1), 0, 0, 0, 0, 0, 0, false, false); - } - - public static void ignoreFrogs(Client client) { - String type = client.playerMagicBook == 0 ? "modern" : "ancient"; - client.getPlayerAssistant().startTeleport(6861, 5834, 0, type); - spawnFrogs(client); - spawnBasedOnGender(client); - client.ignoreFrog = true; - } - - public static void giveReward(Client client) { - client.getItemAssistant().addItem(6183, 1); - } - - public static void spawnFrogs(Client client) { - for (int[] element : FROG_DATA) { - NpcHandler.spawnNpc(client, element[0], client.absX + Misc.random(1), client.absY + Misc.random(1), 0, 0, 0, 0, 0, 0, false, false); - } - } -} diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/GenieLamp.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/GenieLamp.java deleted file mode 100644 index f2b28b38..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/GenieLamp.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.game.npcs.NpcHandler; -import com.rs2.game.players.Client; -import com.rs2.util.Misc; - -/** - * @author Aintaro - */ - -public class GenieLamp { - - private static final int GENIE_LAMP1 = 7498;// , GENIE_LAMP2 = 6543; - - private static int expAmount; - - public static boolean spawnGenieNpc(Client c) { - if (Misc.random(100) == 1 && !c.inWild()) { - NpcHandler.spawnNpc(c, 409, c.absX, c.absY + 1, 0, 0, 0, 0, 0, 0, - false, false); - return true; - } - return false; - } - - public static void removeGenieNpc(Client c) { - NpcHandler.npcs[c.lastNpcClickIndex].absX = 0; - NpcHandler.npcs[c.lastNpcClickIndex].absY = 0; - } - - public static void rubGenieLamp(Client c, int itemId) { - if (itemId == GENIE_LAMP1) {// || itemId == GENIE_LAMP2) { - c.getPacketSender().sendMessage("You rub the lamp..."); - c.getPacketSender().showInterface(2808); - } - } - - private static int[][] genieData = { { 10252, 0 }, { 11000, 1 }, - { 10253, 2 }, { 11001, 3 }, { 10254, 4 }, { 11002, 5 }, - { 10255, 6 }, { 11011, 7 }, { 11013, 8 }, { 11014, 9 }, - { 11010, 10 }, { 11012, 11 }, { 11006, 12 }, { 11009, 13 }, - { 11008, 14 }, { 11004, 15 }, { 11003, 16 }, { 11005, 17 }, - { 47002, 18 }, { 54090, 19 }, { 11007, 20 }, }; - public String statName[] = { "attack", "defence", "strength", "hitpoints", - "range", "prayer", "magic", "cooking", "woodcutting", "fletching", - "fishing", "firemaking", "crafting", "smithing", "mining", - "herblore", "agility", "thieving", "slayer", "farming", - "runecrafting" }; - - private static void whatSkillAreWeLookingFor(Client c, int actionButtonId) { - for (int[] genie : genieData) { - if (genie[0] == actionButtonId) { - if (c.getItemAssistant().playerHasItem(GENIE_LAMP1, 1)) { - c.getItemAssistant().deleteItem(GENIE_LAMP1, 1); - expAmount = 10 * c.playerLevel[genie[1]]; - c.getPlayerAssistant().addSkillXP(expAmount, genie[1]); - // c.getDH().sendStatement( - // "You gained " + expAmount * Config.SERVER_EXP_BONUS - // + " experience."); - c.nextChat = 0; - break; - /* - * } else if - * (c.getItemAssistant().playerHasItem(GENIE_LAMP2, 1)) { - * c.getItemAssistant().deleteItem(GENIE_LAMP2, 1); - * expAmount = 10 * c.playerLevel[genie[1]]; - * c.getPlayerAssistant().addSkillXP(expAmount, genie[1]); - * //c.getDH().sendStatement( //"You gained " + expAmount * - * Config.SERVER_EXP_BONUS // + " experience."); c.nextChat - * = 0; break; - */ - } - } - } - } - - public static boolean genieInterfaceButtons(Client c, int actionButtonId) { - switch (actionButtonId) { - case 10252: - case 10253: - case 10254: - case 10255: - case 11000: - case 11001: - case 11002: - case 11003: - case 11004: - case 11005: - case 11006: - case 11007: - case 47002: - case 54090: - case 11008: - case 11009: - case 11010: - case 11011: - case 11012: - case 11013: - case 11014: - whatSkillAreWeLookingFor(c, actionButtonId); - return true; - } - return false; - } -} diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/RandomEventHandler.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/RandomEventHandler.java deleted file mode 100644 index 739bea6a..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/RandomEventHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.game.players.Player; -import com.rs2.util.Misc; - -/** - * Eventhandler class - * @author Andrew (Mr Extremez) - */ - -public class RandomEventHandler { - - public static int CALL_RANDOM = 350 + Misc.random(100); - - public static void resetEvent(Player c) { - c.randomActions = 0; - } - - private static int[][] FAIL_COORDS = { { 3333, 3333 }, { 3196, 3193 }, - { 3084, 3549 }, { 2974, 3346 }, { 2781, 3506 }, { 2810, 3508 }, }; - - public static void failEvent(Player client) { - int loc = Misc.random(FAIL_COORDS.length - 1); - client.teleportToX = FAIL_COORDS[loc][0]; - client.teleportToY = FAIL_COORDS[loc][1]; - client.heightLevel = 0; - client.getPacketSender().sendMessage("You wake up in a strange location..."); - resetEvent(client); - client.getPacketSender().closeAllWindows(); - } - - public static void callRandom(Player c) { // add all random events here - if (c.inFightCaves() || c.playerEquipment[c.playerWeapon] == 4024 || c.tutorialProgress < 36) { - return; - } - int randomEvent = Misc.random(3); - switch (randomEvent) { - case 0: - SandwhichLady.openSandwhichLady(c); - resetEvent(c); - break; - case 1: - if (c.chickenSpawned == false) { - EvilChicken.spawnChicken(c); - resetEvent(c); - } - break; - case 2: - FreakyForester.teleportToLocation(c); - resetEvent(c); - break; - case 3: - Swarm.spawnSwarm(c); - resetEvent(c); - break; - default: - System.out.println("Error no random event called for " + c.playerName + "."); - break; - } - } - - public static void addRandom(Player c) { - if (c.randomEventsEnabled) { - if (c.randomActions >= CALL_RANDOM) { - callRandom(c); - if (c.playerIsBusy() && !c.hasSandwhichLady) { - c.getPacketSender().closeAllWindows(); - } - } else { - int nextRandom = CALL_RANDOM - c.randomActions; - if (c.playerRights == 3) { - c.getPacketSender().sendMessage("Next random will be in " + nextRandom + " more random actions."); - } - c.randomActions += 1; - } - } - } -} diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/RiverTroll.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/RiverTroll.java deleted file mode 100644 index 2d036e15..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/RiverTroll.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.Constants; -import com.rs2.game.npcs.NpcHandler; -import com.rs2.game.players.Player; -import com.rs2.util.Misc; - -public class RiverTroll { - - public static boolean hasRiverTroll = false; - - private static int[][] riverTroll = { { 3, 10, 391, 19, 1 }, - { 11, 20, 392, 40, 1 }, { 21, 40, 393, 80, 3 }, - { 61, 90, 394, 105, 4 }, { 91, 110, 395, 120, 5 }, - { 111, 138, 396, 150, 7 }, }; - - public static void spawnRiverTroll(Player client) { - for (int[] element : riverTroll) { - if (hasRiverTroll == false) { - if (client.combatLevel >= element[0] && client.combatLevel <= element[1] && hasRiverTroll == false) { - NpcHandler.spawnNpc(client, element[2], client.absX + Misc.random(1), client.absY + Misc.random(1), client.heightLevel, 0, element[3], element[4], client.playerLevel[Constants.ATTACK] * 2, client.playerLevel[Constants.DEFENCE] * 2, true, false); - client.randomActions = 0; - hasRiverTroll = true; - NpcHandler.npcs[element[2]].forceChat("Fishies be mine! Leave dem fishies!"); - } - } - } - } -} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/RockGolem.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/RockGolem.java deleted file mode 100644 index 5bf72e28..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/RockGolem.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.game.npcs.NpcHandler; -import com.rs2.game.players.Client; -import com.rs2.util.Misc; - -public class RockGolem { - - public static int[][] rockGolem = { - {3, 10, 413, 19, 1}, - {11, 20, 414, 40, 1}, - {21, 40, 415, 80, 3}, - {61, 90, 416, 105, 4}, - {91, 110, 417, 120, 5}, - {111, 138, 418, 150, 7}, - }; - - public static void spawnRockGolem(Client c) { - for (int[] aRockGolem : rockGolem) { - if(!c.golemSpawned) { - if (c.combatLevel >= aRockGolem[0] && c.combatLevel <= aRockGolem[1]) { - NpcHandler.spawnNpc(c, aRockGolem[2], c.getX() + Misc.random(1), c.getY() + Misc.random(1), c.heightLevel, 0, aRockGolem[3], aRockGolem[4], aRockGolem[4] * 10, aRockGolem[4] * 10, true, false); - c.golemSpawned = true; - NpcHandler.npcs[aRockGolem[2]].forceChat("Raarrrgghh! Flee human!"); - } - } - } - } - -} diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/SandwhichLady.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/SandwhichLady.java deleted file mode 100644 index a8ffefcc..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/SandwhichLady.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.game.players.Player; -import com.rs2.util.Misc; - -public class SandwhichLady { - - private static int itemType; - - public static void handleOptions(Player player, int actionbuttonId) { - if (player.hasSandwhichLady) { - switch (actionbuttonId) { - case 63013: - if (itemType == 0) { - player.getPacketSender().closeAllWindows(); - player.getItemAssistant().addItem(2323, 1); - player.getPacketSender() - .sendMessage( - "Congratulations, you have completed the random event!"); - } else { - player.getPacketSender().sendMessage( - "You have chosen the wrong item!"); - RandomEventHandler.failEvent(player); - } - player.hasSandwhichLady = false; - break; - - case 63014: - if (itemType == 1) { - player.getPacketSender().closeAllWindows(); - player.getItemAssistant().addItem(1971, 1); - player.getPacketSender() - .sendMessage( - "Congratulations, you have completed the random event!"); - } else { - player.getPacketSender().sendMessage( - "You have chosen the wrong item!"); - RandomEventHandler.failEvent(player); - } - player.hasSandwhichLady = false; - break; - - case 63015: - if (itemType == 2) { - player.getPacketSender().closeAllWindows(); - player.getItemAssistant().addItem(1973, 1); - player.getPacketSender() - .sendMessage( - "Congratulations, you have completed the random event!"); - } else { - player.getPacketSender().sendMessage( - "You have chosen the wrong item!"); - RandomEventHandler.failEvent(player); - } - player.hasSandwhichLady = false; - break; - - case 63009: - if (itemType == 3) { - player.getPacketSender().closeAllWindows(); - player.getItemAssistant().addItem(6961, 10); - player.getPacketSender() - .sendMessage( - "Congratulations, you have completed the random event!"); - } else { - player.getPacketSender().sendMessage( - "You have chosen the wrong item!"); - RandomEventHandler.failEvent(player); - } - player.hasSandwhichLady = false; - break; - - case 63010: - if (itemType == 4) { - player.getPacketSender().closeAllWindows(); - player.getItemAssistant().addItem(6962, 1); - player.getPacketSender() - .sendMessage( - "Congratulations, you have completed the random event!"); - } else { - player.getPacketSender().sendMessage( - "You have chosen the wrong item!"); - RandomEventHandler.failEvent(player); - } - player.hasSandwhichLady = false; - break; - - case 63011: - if (itemType == 5) { - player.getPacketSender().closeAllWindows(); - player.getItemAssistant().addItem(6965, 1); - player.getPacketSender().sendMessage("Congratulations, you have completed the random event!"); - } else { - player.getPacketSender().sendMessage("You have chosen the wrong item!"); - RandomEventHandler.failEvent(player); - } - player.hasSandwhichLady = false; - break; - - case 63012: - if (itemType == 6) { - player.getPacketSender().closeAllWindows(); - player.getItemAssistant().addItem(2309, 1); - player.getPacketSender().sendMessage("Congratulations, you have completed the random event!"); - } else { - player.getPacketSender().sendMessage("You have chosen the wrong item!"); - RandomEventHandler.failEvent(player); - } - player.hasSandwhichLady = false; - break; - } - } else if (player.hasSandwhichLady == false && actionbuttonId > 63008 && actionbuttonId < 63116) { - player.getPacketSender().sendMessage("You have improperly opened the sandwhich lady interface."); - } - } - - public static void openSandwhichLady(Player c) { - c.hasSandwhichLady = true; - c.getPacketSender().sendString(" ", 16131); - c.getPacketSender().showInterface(16135); - int randomMessage = Misc.random(6); - switch (randomMessage) { - case 0: - c.getPacketSender().sendString("Please select the pie.", - 16145); - itemType = 0; - break; - case 1: - c.getPacketSender().sendString("Please select the kebab.", - 16145); - itemType = 1; - break; - case 2: - c.getPacketSender().sendString( - "Please select the chocolate.", 16145); - itemType = 2; - break; - case 3: - c.getPacketSender().sendString("Please select the bagel.", - 16145); - itemType = 3; - break; - case 4: - c.getPacketSender().sendString( - "Please select the triangle sandwich.", 16145); - itemType = 4; - break; - case 5: - c.getPacketSender().sendString( - "Please select the square sandwich.", 16145); - itemType = 5; - break; - case 6: - c.getPacketSender().sendString("Please select the bread.", - 16145); - itemType = 6; - break; - } - } -} diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Shade.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Shade.java deleted file mode 100644 index 0500cf1f..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Shade.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.game.npcs.NpcHandler; -import com.rs2.game.players.Player; -import com.rs2.util.Misc; - -public class Shade { - - private static int[][] shade = { { 3, 10, 425, 19, 1 }, - { 11, 20, 426, 40, 3 }, { 21, 40, 427, 60, 5 }, - { 41, 60, 428, 80, 8 }, { 61, 90, 429, 105, 11 }, - { 91, 138, 430, 120, 13 }, }; - - public static void spawnShade(Player c) { - for (int[] element : shade) { - if (c.shadeSpawned == false) { - if (c.combatLevel >= element[0] - && c.combatLevel <= element[1]) { - NpcHandler - .spawnNpc(c, element[2], - c.absX + Misc.random(1), c.absY - + Misc.random(1), c.heightLevel, - 0, - element[3], // HP - element[4], // maxhit - (int) (NpcHandler.getNpcListCombat(element[3]) * 1.5), // defence - (int) (NpcHandler.getNpcListCombat(element[3]) * 1.5), - true, false); // attack - c.randomActions = 0; - c.shadeSpawned = true; - } - } - } - } -} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Swarm.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Swarm.java deleted file mode 100644 index 9068c760..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Swarm.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.Constants; -import com.rs2.game.npcs.NpcHandler; -import com.rs2.game.players.Client; -import com.rs2.game.players.Player; -import com.rs2.util.Misc; - -/** - * Swarm Event - * @author Andrew (I'm A Boss on Rune-Server, Mr Extremez on Moparscape & Runelocus) - */ - -public class Swarm { - - private static int checkStats(Player c, boolean bot) { - if (bot) { - return c.getPlayerAssistant().getLevelForXP(c.playerXP[Constants.HITPOINTS]) * 3; - } else { - return c.getPlayerAssistant().getLevelForXP(c.playerXP[Constants.HITPOINTS]) * 2; - } - } - - /** - * Spawns the swarm. - * - * @param c - */ - public static void spawnSwarm(Player c) { - NpcHandler.spawnNpc(c, // param - 411, // npctype - c.absX + Misc.random(1), // posX - c.absY + Misc.random(1), // posY - c.heightLevel, // height - 0, // walkingtype - 1, // HP - 2, // maxhit - checkStats(c, false), - 3 * c.combatLevel, // defence - true, // attackplayer - false); // headicon - c.autoRet = 0; - } - - /** - * Spawns the swarm. If suspect a botter ... this one is stronger, botter - * has to react faster to survive. - * - * @param c - */ - public static void checkBot(Client client) { - NpcHandler.spawnNpc(client, // param - 411, // npctype - client.absX + Misc.random(1), // posX - client.absY + Misc.random(1), // posY - client.heightLevel, // height - 0, // walkingtype - 1, // HP - 6, // maxhit - checkStats(client, true), // attack - 4 * client.combatLevel, // defence - true, // attackplayer - false); // headicon - client.autoRet = 0; - } -} diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/TreeSpirit.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/TreeSpirit.java deleted file mode 100644 index f42d1952..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/TreeSpirit.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.Constants; -import com.rs2.game.npcs.NpcHandler; -import com.rs2.game.players.Player; -import com.rs2.util.Misc; - -public class TreeSpirit { - - private static int[][] treeSpirit = { - // combat, combat 2, npcid, hitpoints, levels - { 3, 10, 438, 28, 1 }, { 11, 20, 439, 36, 1 }, - { 21, 40, 440, 57, 3 }, { 61, 90, 441, 90, 4 }, - { 91, 110, 442, 130, 5 }, { 111, 138, 443, 160, 7 }, }; - - private static int checkStats(Player p) { - return p.getPlayerAssistant().getLevelForXP(p.playerXP[Constants.HITPOINTS]) * 2; - } - - public static void spawnTreeSpirit(Player p) { - for (int[] element : treeSpirit) { - if (p.treeSpiritSpawned == false) { - if (p.combatLevel >= element[0] && p.combatLevel <= element[1]) { - NpcHandler.spawnNpc(p, element[2], p.absX + Misc.random(1), - p.absY + Misc.random(1), p.heightLevel, 0, element[3], - element[4], checkStats(p), p.playerLevel[Constants.DEFENCE] * 2, true, - false); - NpcHandler.npcs[element[2]] - .forceChat("Leave these woods and never return!"); - p.treeSpiritSpawned = true; - p.randomActions = 0; - } - } - } - } -} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Zombie.java b/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Zombie.java deleted file mode 100644 index c9abadd3..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/content/randomevents/Zombie.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.rs2.game.content.randomevents; - -import com.rs2.game.npcs.NpcHandler; -import com.rs2.game.players.Player; -import com.rs2.util.Misc; - -public class Zombie { - - private static int[][] zombie = { { 3, 10, 419, 28, 2, 10, 10 }, - { 11, 20, 420, 36, 4, 20, 20 }, { 21, 40, 421, 57, 6, 30, 30 }, - { 61, 90, 422, 90, 8, 40, 40 }, { 91, 110, 423, 130, 10, 50, 50 }, - { 111, 138, 424, 160, 12, 60, 60 } }; - - public static void spawnZombie(Player c) { - for (int[] element : zombie) { - if (c.zombieSpawned == false) { - if (c.combatLevel >= element[0] && c.combatLevel <= element[1]) { - NpcHandler.spawnNpc(c, element[2], c.absX + Misc.random(1), - c.absY + Misc.random(1), c.heightLevel, 0, element[3], - element[4], element[5], element[6], true, false); - c.randomActions = 0; - c.zombieSpawned = true; - NpcHandler.npcs[element[2]].forceChat("Braaaainssss!"); - } - } - } - } -} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/cooking/Cooking.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/cooking/Cooking.java index c723323f..4526dacb 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/cooking/Cooking.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/cooking/Cooking.java @@ -7,7 +7,7 @@ import com.rs2.event.CycleEventHandler; import com.rs2.game.content.StaticItemList; import com.rs2.game.content.StaticObjectList; import com.rs2.game.content.music.sound.SoundList; -import com.rs2.game.content.randomevents.RandomEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.items.DeprecatedItems; import com.rs2.game.items.ItemConstants; @@ -199,7 +199,7 @@ public class Cooking extends SkillHandler { final CookingItems item = forId(itemId); if (item != null) { setCooking(player, true); - RandomEventHandler.addRandom(player); + player.post(new RandomActionEvent("general")); player.getPacketSender().closeAllWindows(); player.doAmount = amount; if (player.doAmount > player.getItemAssistant().getItemAmount(itemId)) { diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/cooking/Potatoes.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/cooking/Potatoes.java index e40f942c..fccc6719 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/cooking/Potatoes.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/cooking/Potatoes.java @@ -2,7 +2,7 @@ package com.rs2.game.content.skills.cooking; import com.rs2.Constants; import com.rs2.game.content.StaticItemList; -import com.rs2.game.content.randomevents.RandomEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.players.Player; @@ -107,7 +107,7 @@ public class Potatoes extends SkillHandler { c.getPacketSender().sendMessage("You put the topping on."); c.getItemAssistant().addItem(potato.getNewPotatoID(), 1); c.getPlayerAssistant().addSkillXP(potato.getXP(), Constants.COOKING); - RandomEventHandler.addRandom(c); + c.post(new RandomActionEvent("general")); } else { c.getPacketSender().sendMessage("You need a cooking level of " + potato.getReq() + " to make this potato."); } diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/core/Fishing.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/core/Fishing.java index ea1e14b8..4cc085ae 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/core/Fishing.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/core/Fishing.java @@ -4,8 +4,7 @@ import com.rs2.Constants; import com.rs2.event.CycleEvent; import com.rs2.event.CycleEventContainer; import com.rs2.event.CycleEventHandler; -import com.rs2.game.content.randomevents.RandomEventHandler; -import com.rs2.game.content.randomevents.RiverTroll; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.items.DeprecatedItems; import com.rs2.game.players.Player; @@ -17,12 +16,7 @@ import static com.rs2.game.content.StaticNpcList.*; public class Fishing extends SkillHandler { public static void randomEvents(Player client) { - if (Misc.random(350) == 5) { - RiverTroll.spawnRiverTroll(client); - } - if (RiverTroll.hasRiverTroll == false) { - RandomEventHandler.addRandom(client); - } + client.post(new RandomActionEvent("fishing")); } /** diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/core/Mining.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/core/Mining.java index 3b7507b2..61a1a1de 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/core/Mining.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/core/Mining.java @@ -4,6 +4,7 @@ import com.rs2.Constants; import com.rs2.event.CycleEvent; import com.rs2.event.CycleEventContainer; import com.rs2.event.CycleEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.StaticItemList; import com.rs2.game.content.StaticObjectList; import com.rs2.game.items.DeprecatedItems; @@ -238,6 +239,9 @@ public class Mining { player.getItemAssistant().addItem(oreID, 1); player.getPlayerAssistant().addSkillXP(rock.getXp(), Constants.MINING); player.getPacketSender().sendMessage("You manage to mine some " + DeprecatedItems.getItemName(oreID).toLowerCase() + "."); + if (player.tutorialProgress >= 36) { + player.post(new RandomActionEvent("mining")); + } } else { obtainGem(player); } diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/crafting/SoftClay.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/crafting/SoftClay.java index 36ecde2a..bc961497 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/crafting/SoftClay.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/crafting/SoftClay.java @@ -3,7 +3,7 @@ package com.rs2.game.content.skills.crafting; import com.rs2.event.CycleEvent; import com.rs2.event.CycleEventContainer; import com.rs2.event.CycleEventHandler; -import com.rs2.game.content.randomevents.RandomEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.players.Player; /** @@ -30,7 +30,7 @@ public class SoftClay { player.getItemAssistant().deleteItem(CLAY, 1); player.getItemAssistant().addItem(SOFT_CLAY, 1); player.doAmount--; - RandomEventHandler.addRandom(player); + player.post(new RandomActionEvent("general")); player.getPacketSender().sendMessage("You turn the clay into soft clay."); if (player.disconnected || player.isSpinning == false || player.doAmount == 0) { container.stop(); diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/firemaking/Firemaking.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/firemaking/Firemaking.java index 2e970f92..fb7d1611 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/firemaking/Firemaking.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/firemaking/Firemaking.java @@ -25,24 +25,105 @@ public class Firemaking { c.logLit = false; } + private static boolean isFiremakingItem(int itemId) { + return itemId == 590 || itemId == 7329 || itemId == 7330 || itemId == 7331; + } + + private static boolean isTileBlocked(int x, int y, int height) { + return GameEngine.objectManager.getObject(x, y, height) != null + || GameEngine.objectHandler.objectExists(x, y, height) != null + || Region.hasSceneryObject(x, y, height) + || (Region.getClipping(x, y, height) & 0x1280100) != 0; + } + + /** + * Authentic RS2 per-attempt firemaking roll scaled by Firemaking level vs log tier. + */ + private static boolean canLightLog(int level, LogData log) { + int low; + int high; + switch (log) { + case OAK: + low = 50; + high = 380; + break; + case WILLOW: + low = 40; + high = 300; + break; + case TEAK: + low = 35; + high = 280; + break; + case ARCTIC_PINE: + low = 32; + high = 260; + break; + case MAPLE: + low = 30; + high = 250; + break; + case MAHOGANY: + low = 28; + high = 235; + break; + case EUCALYPTUS: + low = 24; + high = 215; + break; + case YEW: + low = 22; + high = 200; + break; + case MAGIC: + low = 18; + high = 175; + break; + case LOG: + case ACHEY: + case RED: + case BLUE: + case RED2: + default: + low = 65; + high = 513; + break; + } + int clampedLevel = Math.max(1, Math.min(99, level)); + double chance = (low * (99 - clampedLevel) + high * (clampedLevel - 1)) / 98.0; + return Misc.random(255) < chance; + } + public static void attemptFire(final Player c, final int itemUsed, final int usedWith, final int x, final int y, final boolean groundObject) { - int firemakingItems[] = {590, 7329, 7330, 7331}; - for (int i = 0; i < firemakingItems.length; i++) { if (c.pickedUpFiremakingLog) { c.getPacketSender().sendMessage("You can't do that!"); c.pickedUpFiremakingLog = false; return; } - if (c.isFiremaking && c.logLit == false) { + if (c.isFiremaking) { return; } if (!SkillHandler.FIREMAKING) { c.getPacketSender().sendMessage("This skill is currently disabled."); return; } + final int logId; + final int firemakingItem; + if (isFiremakingItem(usedWith)) { + firemakingItem = usedWith; + logId = itemUsed; + } else if (isFiremakingItem(itemUsed)) { + firemakingItem = itemUsed; + logId = usedWith; + } else { + return; + } for (final LogData l : LogData.values()) { - final int logId = usedWith == firemakingItems[i] ? itemUsed : usedWith; if (logId == l.getLogId()) { + if (firemakingItem != 590 && logId != 1511) { + c.getPacketSender().sendMessage("Nothing interesting happens."); + return; + } if (c.playerLevel[Constants.FIREMAKING] < l.getLevel()) { c.getPacketSender().sendMessage("You need a firemaking level of " + l.getLevel() + " to light " + DeprecatedItems.getItemName(logId)); return; @@ -55,54 +136,34 @@ public class Firemaking { c.getPacketSender().sendMessage("The dwarves won't be happy if you light a fire here."); return; } - if (GameEngine.objectManager.objectExists(c.absX, c.absY)) { + if (isTileBlocked(x, y, c.heightLevel)) { c.getPacketSender().sendMessage("You cannot light a fire here."); return; } c.isFiremaking = true; c.logLit = false; boolean notInstant = System.currentTimeMillis() - SkillHandler.lastSkillingAction > 2500; - int cycle = 2; + int cycle = notInstant ? 3 : 2; if (notInstant) { c.getPacketSender().sendMessage("You attempt to light the logs."); c.getPacketSender().sendSound(SoundList.FIRE_LIGHT, 100, 0); - if (!notInstant) { - c.getPacketSender().sendSound(SoundList.FIRST_ATTEMPT, 100, 0);// testing - } if (c.tutorialProgress == 4) { c.getPacketSender().chatbox(6180); c.getDialogueHandler().chatboxText("", "Your character is now attempting to light the fire.", "This should only take a few seconds.", "", "Please wait"); c.getPacketSender().chatbox(6179); } - if (groundObject == false) { + if (!groundObject) { c.getItemAssistant().deleteItem(logId, c.getItemAssistant().getItemSlot(logId), 1); GameEngine.itemHandler.createGroundItem(c, logId, c.absX, c.absY, 1, c.playerId); } - cycle = 3 + Misc.random(6); } else { - if (groundObject == false) { + if (!groundObject) { c.getItemAssistant().deleteItem(logId, c.getItemAssistant().getItemSlot(logId), 1); GameEngine.itemHandler.createGroundItem(c, logId, c.absX, c.absY, 1, c.playerId); } } - int[] dir = { 0, 0 }; - if (Region.getClipping(x - 1, y, c.heightLevel, -1, 0)) { - dir[0] = -1; - dir[1] = 0; - } else if (Region.getClipping(x + 1, y, c.heightLevel, 1, 0)) { - dir[0] = 1; - dir[1] = 0; - } else if (Region.getClipping(x, y - 1, c.heightLevel, 0, -1)) { - dir[0] = 0; - dir[1] = -1; - } else if (Region.getClipping(x, y + 1, c.heightLevel, 0, 1)) { - dir[0] = 0; - dir[1] = 1; - } - c.startAnimation(733); - c.getPlayerAssistant().walkTo(dir[0], dir[1]); c.stopFiremaking = false; CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() { @@ -110,34 +171,77 @@ public class Firemaking { public void execute(CycleEventContainer container) { if (c.stopFiremaking) { c.stopFiremaking = false; + container.stop(); return; } if (c.isWoodcutting || c.playerIsFletching || c.isFletching) { container.stop(); + return; } if (c.isFiremaking) { + if (isTileBlocked(x, y, c.heightLevel)) { + c.getPacketSender().sendMessage("You cannot light a fire here."); + container.stop(); + return; + } + if (!canLightLog(c.playerLevel[Constants.FIREMAKING], l)) { + c.startAnimation(733); + c.getPacketSender().sendSound(SoundList.FIRE_LIGHT, 100, 0); + container.setTick(3); + return; + } + int[] dir = { 0, 0 }; + if (Region.getClipping(x - 1, y, c.heightLevel, -1, 0)) { + dir[0] = -1; + } else if (Region.getClipping(x + 1, y, c.heightLevel, 1, 0)) { + dir[0] = 1; + } else if (Region.getClipping(x, y - 1, c.heightLevel, 0, -1)) { + dir[1] = -1; + } else if (Region.getClipping(x, y + 1, c.heightLevel, 0, 1)) { + dir[1] = 1; + } GameEngine.itemHandler.removeGroundItem(c, logId, x, y, false); c.getPacketSender().sendSound(SoundList.FIRE_SUCCESSFUL, 100, 0); - if (itemUsed == 7331 || usedWith == 7331) - new Object(11406, x, y, 0, 0, 10, -1, 200); - else if (itemUsed == 7330 || usedWith == 7330) - new Object(11405, x, y, 0, 0, 10, -1, 200); - else if (itemUsed == 7329 || usedWith == 7329) - new Object(11404, x, y, 0, 0, 10, -1, 200); + final int fireId; + if (firemakingItem == 7331) + fireId = 11406; + else if (firemakingItem == 7330) + fireId = 11405; + else if (firemakingItem == 7329) + fireId = 11404; else - new Object(2732, x, y, 0, 0, 10, -1, 200); + fireId = 2732; + final int fireDuration = 100 + Misc.random(98); + final Object fireObj = new Object(fireId, x, y, c.heightLevel, 0, 10, -1, fireDuration + 10); c.getPacketSender().sendMessage("The fire catches and the logs begin to burn."); c.getPlayerAssistant().addSkillXP((int) l.getXp(), 11); + c.getPlayerAssistant().walkTo(dir[0], dir[1]); if (c.tutorialProgress == 4) { c.getDialogueHandler().sendDialogues(3016, 943); } + CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() { + @Override + public void execute(CycleEventContainer container) { + if (c.playerIsCooking) { + Cooking.setCooking(c, false); + } + if (GameEngine.objectManager.objects.remove(fireObj)) { + GameEngine.objectManager.updateObject(fireObj); + } + GameEngine.itemHandler.createGroundItem(c, 592, x, y, 1, c.getId()); + container.stop(); + } + @Override + public void stop() { + } + }, fireDuration); CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() { @Override public void execute(CycleEventContainer container) { - c.turnPlayerTo(x - dir[0], y - dir[1]); - c.logLit = true; - stopFiremaking(c); + if (!c.isFiremaking) { + c.turnPlayerTo(x, y); + } container.stop(); } @@ -159,22 +263,7 @@ public class Firemaking { stopFiremaking(c); } }, cycle); - CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() { - @Override - public void execute(CycleEventContainer container) { - if (c.playerIsCooking) { - Cooking.setCooking(c, false); - } - GameEngine.objectHandler.createAnObject(c, -1, x, y); - GameEngine.itemHandler.createGroundItem(c, 592, x, y, 1, c.getId()); - container.stop(); - } - @Override - public void stop() { - - } - }, 100 + Misc.random(98)); - } + return; } } } diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/prayer/Prayer.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/prayer/Prayer.java index 217a0ff4..72914fb3 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/prayer/Prayer.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/prayer/Prayer.java @@ -3,9 +3,8 @@ package com.rs2.game.content.skills.prayer; import com.rs2.event.CycleEvent; import com.rs2.event.CycleEventContainer; import com.rs2.event.CycleEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.music.sound.SoundList; -import com.rs2.game.content.randomevents.Shade; -import com.rs2.game.content.randomevents.Zombie; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.items.DeprecatedItems; import com.rs2.game.players.Player; @@ -56,13 +55,6 @@ public class Prayer { } private static void handleBones(final Player c, int i, int slot) { - if(c.randomEventsEnabled) { - if (Misc.random(300) == 4 && c.shadeSpawned == false) { - Zombie.spawnZombie(c); - } else if (Misc.random(300) == 2 && c.zombieSpawned == false) { - Shade.spawnShade(c); - } - } for (final int[] element : data) { if (i == element[0]) { if (!SkillHandler.PRAYER) { @@ -72,6 +64,7 @@ public class Prayer { c.getItemAssistant().deleteItem(element[0], slot, 1); c.getPlayerAssistant().addSkillXP(element[1], 5); c.buryDelay = System.currentTimeMillis(); + c.post(new RandomActionEvent("prayer")); c.startAnimation(827); c.getPacketSender().sendSound(SoundList.BONE_BURY, 100, 0); c.getPacketSender().sendMessage("You dig a hole in the ground..."); diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/runecrafting/Runecrafting.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/runecrafting/Runecrafting.java index aa8c9523..dc35cfab 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/runecrafting/Runecrafting.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/runecrafting/Runecrafting.java @@ -2,7 +2,7 @@ package com.rs2.game.content.skills.runecrafting; import com.rs2.Constants; import com.rs2.game.content.music.sound.SoundList; -import com.rs2.game.content.randomevents.RandomEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.players.Player; @@ -150,7 +150,7 @@ public class Runecrafting { public boolean craftRunes(int obj) { Altar_Data ad = forObj(obj); if (ad != null) { - RandomEventHandler.addRandom(c); + c.post(new RandomActionEvent("general")); if (!SkillHandler.RUNECRAFTING) { c.getPacketSender().sendMessage("This skill is currently disabled."); return false; diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/Pickpocket.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/Pickpocket.java index 537ef7d3..1f815715 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/Pickpocket.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/Pickpocket.java @@ -5,7 +5,7 @@ import com.rs2.event.CycleEvent; import com.rs2.event.CycleEventContainer; import com.rs2.event.CycleEventHandler; import com.rs2.game.content.music.sound.SoundList; -import com.rs2.game.content.randomevents.RandomEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.npcs.NpcHandler; import com.rs2.game.players.Player; @@ -229,7 +229,7 @@ public class Pickpocket extends SkillHandler { player.getPacketSender().sendMessage("You attempt to pick the " + NpcHandler.getNpcListName(n.getNpc(npcId)).toLowerCase() + "'s pocket."); player.startAnimation(881); if (Misc.random(player.playerLevel[Constants.THIEVING] + 5) < Misc.random(n.getLevel())) { - RandomEventHandler.addRandom(player); + player.post(new RandomActionEvent("general")); CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() { @Override public void execute(CycleEventContainer container) { diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/SearchForTraps.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/SearchForTraps.java index 9f05ca6e..0734936d 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/SearchForTraps.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/SearchForTraps.java @@ -4,7 +4,7 @@ import com.rs2.Constants; import com.rs2.event.CycleEvent; import com.rs2.event.CycleEventContainer; import com.rs2.event.CycleEventHandler; -import com.rs2.game.content.randomevents.RandomEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.players.Player; import com.rs2.util.Misc; @@ -81,7 +81,7 @@ public class SearchForTraps { client.getPacketSender().sendMessage("You search the chest for traps"); client.startAnimation(536); - RandomEventHandler.addRandom(client); + client.post(new RandomActionEvent("general")); int resetTime = getChestResetTime(chest.getChestId()); client.getPacketSender().sendMessage("You find a trap on the chest..."); client.getPacketSender().sendMessage("You disable the trap"); diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/Stalls.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/Stalls.java index 18d14de1..ca551807 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/Stalls.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/thieving/Stalls.java @@ -7,7 +7,7 @@ import com.rs2.GameEngine; import com.rs2.event.CycleEvent; import com.rs2.event.CycleEventContainer; import com.rs2.event.CycleEventHandler; -import com.rs2.game.content.randomevents.RandomEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.npcs.NpcHandler; import com.rs2.game.players.Player; @@ -152,7 +152,7 @@ public class Stalls { return; } p.startAnimation(832); - RandomEventHandler.addRandom(p); + p.post(new RandomActionEvent("general")); int respawnTime = getRespawnTime(s.getObject()); GameEngine.objectHandler.createAnObject(p, 634, x, y, 0, getSpecialFace(p, s)); p.getPlayerAssistant().addSkillXP((int) s.getXp(), Constants.THIEVING); diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/skills/woodcutting/Woodcutting.java b/2006Scape Server/src/main/java/com/rs2/game/content/skills/woodcutting/Woodcutting.java index c6094531..a4c3987b 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/skills/woodcutting/Woodcutting.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/skills/woodcutting/Woodcutting.java @@ -4,9 +4,8 @@ import com.rs2.Constants; import com.rs2.event.CycleEvent; import com.rs2.event.CycleEventContainer; import com.rs2.event.CycleEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.music.sound.SoundList; -import com.rs2.game.content.randomevents.RandomEventHandler; -import com.rs2.game.content.randomevents.TreeSpirit; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.items.DeprecatedItems; import com.rs2.game.objects.Object; @@ -327,11 +326,8 @@ public class Woodcutting { if (p.isWoodcutting) { BirdNest.birdNests(p); } - if (p.isWoodcutting && p.tutorialProgress >= 36 && p.treeSpiritSpawned == false) { - RandomEventHandler.addRandom(p); - } - if (p.isWoodcutting && Misc.random(350) == 69 && p.tutorialProgress >= 36 && p.randomEventsEnabled) { - TreeSpirit.spawnTreeSpirit(p); + if (p.isWoodcutting && p.tutorialProgress >= 36) { + p.post(new RandomActionEvent("woodcutting")); } if (p.playerIsFletching || p.isFiremaking) { container.stop(); diff --git a/2006Scape Server/src/main/java/com/rs2/game/content/traveling/DesertHeat.java b/2006Scape Server/src/main/java/com/rs2/game/content/traveling/DesertHeat.java index c18aeba6..1e77312e 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/content/traveling/DesertHeat.java +++ b/2006Scape Server/src/main/java/com/rs2/game/content/traveling/DesertHeat.java @@ -1,9 +1,7 @@ package com.rs2.game.content.traveling; import com.rs2.Constants; -import com.rs2.event.CycleEvent; -import com.rs2.event.CycleEventContainer; -import com.rs2.event.CycleEventHandler; +import com.rs2.game.content.StaticItemList; import com.rs2.game.items.ItemConstants; import com.rs2.game.players.Player; import com.rs2.util.Misc; @@ -16,10 +14,6 @@ import com.rs2.world.Boundary; */ public class DesertHeat { - /** - * Damage dealt to player - */ - private static int DAMAGE = 1+Misc.random(8); /** * Waterskin animation */ @@ -27,19 +21,15 @@ public class DesertHeat { /** * Time player has if they don't have protection (90 seconds) */ - private static int REGULAR_TIMER = 90000; + private static final int REGULAR_TIMER = 90000; /** - * Integer to check if player has waterskins + * Waterskins before and after, ordered from lowest to highest dose */ - private static int waterskin = -1; - /** - * Waterskins before and after - */ - private static int[][] WATERSKINS = { - {1825, 1823},//waterskin 3 - {1827, 1825},//waterskin 2 - {1829, 1827},//waterskin 1 - {1831, 1829}//waterskin 0 + private static final int[][] WATERSKINS = { + {StaticItemList.WATERSKIN0, StaticItemList.WATERSKIN1}, + {StaticItemList.WATERSKIN1, StaticItemList.WATERSKIN2}, + {StaticItemList.WATERSKIN2, StaticItemList.WATERSKIN3}, + {StaticItemList.WATERSKIN3, StaticItemList.WATERSKIN4} }; /** * Desert clothes @@ -49,9 +39,10 @@ public class DesertHeat { }; private static void doDamage(Player player) { + int damage = 1 + Misc.random(9); player.getPacketSender().sendMessage("You should get a waterskin for any traveling in the desert."); - player.handleHitMask(DAMAGE); - player.dealDamage(DAMAGE); + player.handleHitMask(damage); + player.dealDamage(damage); player.getPlayerAssistant().refreshSkill(Constants.HITPOINTS); } @@ -78,53 +69,36 @@ public class DesertHeat { } public static void callHeat(final Player player) { - if (!Boundary.isIn(player, Boundary.DESERT) - || player.playerLevel[Constants.HITPOINTS] <= 0 + if (!Boundary.isIn(player, Boundary.DESERT) + || player.heightLevel != 0 || preventHeat(player)) { + player.lastDesert = 0; return; } - CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() { - @Override - public void execute(CycleEventContainer container) { - if (!Boundary.isIn(player, Boundary.DESERT) - || player.playerLevel[Constants.HITPOINTS] <= 0 - || player.disconnected - || preventHeat(player)) { - container.stop(); - return; - } - if (System.currentTimeMillis() - player.lastDesert > getTimer(player)) { - player.lastDesert = System.currentTimeMillis(); - if (!checkWaterskin(player)) { - doDamage(player); - } - container.stop(); - } else if (player.playerLevel[Constants.HITPOINTS] <= 0) { - player.isDead = true; - container.stop(); - } + if (player.playerLevel[Constants.HITPOINTS] <= 0 || player.isDead || player.disconnected) { + return; + } + long now = System.currentTimeMillis(); + if (player.lastDesert == 0) { + player.lastDesert = now; + return; + } + if (now - player.lastDesert >= getTimer(player)) { + player.lastDesert = now; + if (!checkWaterskin(player)) { + doDamage(player); } - @Override - public void stop() { - - } - }, 1); + } } public static boolean checkWaterskin(final Player player) { - for (int i = 0; i < WATERSKINS.length; i++) { - if (player.getItemAssistant().playerHasItem(WATERSKINS[i][1])) { - waterskin = i; - } - } - if (waterskin == -1) {//empty waterskin - return false; - } - if (waterskin >= 0) { - player.getItemAssistant().deleteItem(WATERSKINS[waterskin][1], 1); - player.getItemAssistant().addItem(WATERSKINS[waterskin][0], 1); - player.startAnimation(ANIMATION); - return true; + for (int[] skin : WATERSKINS) { + if (player.getItemAssistant().playerHasItem(skin[1])) { + player.getItemAssistant().deleteItem(skin[1], 1); + player.getItemAssistant().addItem(skin[0], 1); + player.startAnimation(ANIMATION); + return true; + } } return false; } diff --git a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java index 8cb6620e..dfa2ceab 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java +++ b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java @@ -6,8 +6,6 @@ import com.rs2.game.bots.Bot; import com.rs2.game.bots.BotHandler; import com.rs2.game.content.quests.QuestAssistant; import com.rs2.game.content.quests.QuestRewards; -import com.rs2.game.content.randomevents.FreakyForester; -import com.rs2.game.content.randomevents.RandomEventHandler; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.content.skills.farming.Farmers; import com.rs2.game.content.skills.slayer.Slayer; @@ -60,35 +58,6 @@ public class DialogueHandler { player.dialogueAction = 8; break; - case 2: - if (player.canLeaveArea) { - sendNpcChat2( - "Just step through the glowing portal when you're ready", - "to leave, and I'll ensure you get a nice reward.", - player.talkingNpc, "Freaky Forester"); - player.getItemAssistant().deleteItem(6178, player.getItemAssistant().getItemSlot(6178), player.getItemAssistant().getItemAmount(6178)); - } else if (FreakyForester.hasKilledPheasant(player) - && player.getItemAssistant().playerHasItem(6178, 1)) { - sendNpcChat1( - "Thank you. I take that pheasant, you can leave now.", - player.talkingNpc, "Freaky Forester"); - player.canLeaveArea = true; - player.getItemAssistant().deleteItem(6178, player.getItemAssistant().getItemSlot(6178), player.getItemAssistant().getItemAmount(6178)); - } else { - sendNpcChat2("Hello there mate. Can you please kill a " - + FreakyForester.getPheasant(player) + " and", - "bring it back to me and I shall let you leave.", - player.talkingNpc, "Freaky Forester"); - } - player.nextChat = 0; - break;// go to where they appear or whatever - - case 3: - sendNpcChat1("Come back mate! You can't leave yet!", - player.talkingNpc, "Freaky Forester"); - player.nextChat = 0; - break; - case 4: if (player.luthas && player.bananas >= 2) { player.getItemAssistant().addOrDropItem(995, 30); @@ -4294,84 +4263,12 @@ public class DialogueHandler { if (shop != null) { if (shop.getNpc() == player.talkingNpc) { player.getShopAssistant().openShop(shop.getShop()); - RandomEventHandler.addRandom(player); player.nextChat = 0; } } } break; - case 1329: - sendNpcChat2("Hello " + Misc.capitalize(player.playerName) + ".", - "Are you interested in buying anything?", - player.talkingNpc, - NpcHandler.getNpcListName(player.talkingNpc)); - player.nextChat = 1330; - break; - - case 1330: - sendOption("Yes please.", "No Thanks.", - "I have a frog token I would like to exchange."); - player.dialogueAction = 148; - break; - - case 1331: - sendPlayerChat("No thanks."); - player.nextChat = 0; - break; - - case 1332: - sendPlayerChat("Yes please."); - player.nextChat = 1334; - break; - - case 1333: - sendOption("A frog mask please!", "A frog outfit, please!"); - player.dialogueAction = 149; - break; - - case 1334: - player.getShopAssistant().openShop(12); - RandomEventHandler.addRandom(player); - break; - - case 1335: - if (player.getItemAssistant().playerHasItem(6183, 1)) { - sendPlayerChat("A frog mask please!"); - player.getItemAssistant().deleteItem(6183, 1); - player.getItemAssistant().addOrDropItem(6188, 1); - player.nextChat = 0; - } else { - sendNpcChat1("You don't have any frog tokens.", - player.talkingNpc, - NpcHandler.getNpcListName(player.talkingNpc)); - player.nextChat = 0; - } - break; - - case 1336: - if (player.getItemAssistant().playerHasItem(6183, 1) - && player.playerAppearance[0] == 0) { - sendPlayerChat("A frog prince outfit, please!"); - player.getItemAssistant().deleteItem(6183, 1); - player.getItemAssistant().addOrDropItem(6184, 1); - player.getItemAssistant().addOrDropItem(6185, 1); - player.nextChat = 0; - } else if (player.getItemAssistant().playerHasItem(6183, 1) - && player.playerAppearance[0] == 1) { - sendPlayerChat("A frog princess outfit, please!"); - player.getItemAssistant().deleteItem(6183, 1); - player.getItemAssistant().addOrDropItem(6186, 1); - player.getItemAssistant().addOrDropItem(6187, 1); - player.nextChat = 0; - } else { - sendNpcChat1("You don't have any frog tokens.", - player.talkingNpc, - NpcHandler.getNpcListName(player.talkingNpc)); - player.nextChat = 0; - } - break; - case 1337: sendNpcChat1("Hello, would you like some rope?", player.talkingNpc, NpcHandler.getNpcListName(player.talkingNpc)); @@ -4698,7 +4595,6 @@ public class DialogueHandler { } else if (player.npcType == 536) { player.getShopAssistant().openShop(125); } - RandomEventHandler.addRandom(player); player.nextChat = 0; break; diff --git a/2006Scape Server/src/main/java/com/rs2/game/items/UseItem.java b/2006Scape Server/src/main/java/com/rs2/game/items/UseItem.java index ad38e529..2ff1bd25 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/items/UseItem.java +++ b/2006Scape Server/src/main/java/com/rs2/game/items/UseItem.java @@ -197,10 +197,13 @@ public class UseItem { } int firemakingItems[] = {590, 7329, 7330, 7331}; for (int i = 0; i < firemakingItems.length; i++) { - if (itemUsed == firemakingItems[i] || useWith == firemakingItems[i] && player.isFiremaking == false) { - Firemaking.attemptFire(player, itemUsed, useWith, player.absX, player.absY, false); - } else if (itemUsed == firemakingItems[i] || useWith == firemakingItems[i] && player.isFiremaking) { - player.getPacketSender().sendMessage("You can't do that, you are already firemaking."); + if (itemUsed == firemakingItems[i] || useWith == firemakingItems[i]) { + if (!player.isFiremaking) { + Firemaking.attemptFire(player, itemUsed, useWith, player.absX, player.absY, false); + } else { + player.getPacketSender().sendMessage("You can't do that, you are already firemaking."); + } + break; } } if (itemUsed == 1733 || useWith == 1733) { diff --git a/2006Scape Server/src/main/java/com/rs2/game/items/impl/ExperienceLamp.java b/2006Scape Server/src/main/java/com/rs2/game/items/impl/ExperienceLamp.java deleted file mode 100644 index d4f481be..00000000 --- a/2006Scape Server/src/main/java/com/rs2/game/items/impl/ExperienceLamp.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.rs2.game.items.impl; - -import com.rs2.game.players.Player; - -public class ExperienceLamp { - - public static int LAMP = 4447, LAMP_2 = 2528, SKILL_MENU = 2808, - skill = -1; - - /** - * Handles the actionbuttons - * - * @param player - * @param id - */ - public static void buttons(Player player, int id) { - switch (id) { - case 10252: - skill = 0; - player.getPacketSender().sendMessage("You select Attack."); - break; - case 10253: - skill = 2; - player.getPacketSender().sendMessage("You select Strength."); - break; - case 10254: - skill = 4; - player.getPacketSender().sendMessage("You select Ranged."); - break; - case 10255: - skill = 6; - player.getPacketSender().sendMessage("You select Magic."); - break; - case 11000: - skill = 1; - player.getPacketSender().sendMessage("You select Defence."); - break; - case 11001: - skill = 3; - player.getPacketSender().sendMessage("You select Hitpoints."); - break; - case 11002: - skill = 5; - player.getPacketSender().sendMessage("You select Prayer."); - break; - case 11003: - skill = 16; - player.getPacketSender().sendMessage("You select Agility."); - break; - case 11004: - skill = 15; - player.getPacketSender().sendMessage("You select Herblore."); - break; - case 11005: - skill = 17; - player.getPacketSender().sendMessage("You select Thieving."); - break; - case 11006: - skill = 12; - player.getPacketSender().sendMessage("You select Crafting."); - break; - case 11007: - skill = 20; - player.getPacketSender().sendMessage("You select Runecrafting."); - break; - case 47002: - skill = 18; - player.getPacketSender().sendMessage("You select Slayer."); - break; - case 54090: - skill = -1; - player.getPacketSender().sendMessage("You can't select this skill."); - break; - case 11008: - skill = 14; - player.getPacketSender().sendMessage("You select Mining."); - break; - case 11009: - skill = 13; - player.getPacketSender().sendMessage("You select Smithing."); - break; - case 11010: - skill = 10; - player.getPacketSender().sendMessage("You select Fishing."); - break; - case 11011: - skill = 7; - player.getPacketSender().sendMessage("You select Cooking."); - break; - case 11012: - skill = 11; - player.getPacketSender().sendMessage("You select Firemaking."); - break; - case 11013: - skill = 8; - player.getPacketSender().sendMessage("You select Woodcutting."); - break; - case 11014: - skill = 9; - player.getPacketSender().sendMessage("You select Fletching."); - break; - case 11015: - if (skill == -1) { - player.getPacketSender().closeAllWindows(); - } - if (player.getItemAssistant().playerHasItem(LAMP, 1) && skill > -1) {// normal - // lamp - int xp = player.getPlayerAssistant() - .getLevelForXP(player.playerXP[skill]) * 10; - player.getPlayerAssistant().addSkillXP(xp, skill); - player.getItemAssistant().deleteItem(LAMP, 1); - player.getPacketSender().sendMessage( - "@blu@Your wish has been granted!"); - player.getPacketSender().sendMessage( - "@blu@You have been awarded " + xp - + " experience in your selected skill!"); - player.getPacketSender().closeAllWindows(); - } else if (player.getItemAssistant().playerHasItem(LAMP_2, 1) - && skill > -1) {// vote - // reward - player.getItemAssistant().deleteItem(LAMP_2, 1); - player.getPacketSender().sendMessage( - "@blu@Your wish has been granted!"); - addExp(player); - player.getPacketSender().closeAllWindows(); - } - break; - } - } - - public static void addExp(Player c) { - if (c.getPlayerAssistant().getLevelForXP(c.playerXP[skill]) < 20) { - c.getPlayerAssistant().addSkillXP(1000, skill); - c.getPacketSender() - .sendMessage( - "@blu@You have been awarded 1000 experience in your selected skill!"); - } else if (c.getPlayerAssistant().getLevelForXP(c.playerXP[skill]) > 19 - && c.getPlayerAssistant().getLevelForXP(c.playerXP[skill]) < 35) { - c.getPlayerAssistant().addSkillXP(2000, skill); - c.getPacketSender() - .sendMessage( - "@blu@You have been awarded 2000 experience in your selected skill!"); - } else { - c.getPlayerAssistant().addSkillXP(3000, skill); - c.getPacketSender() - .sendMessage( - "@blu@You have been awarded 3000 experience in your selected skill!"); - } - } - - /** - * Rubbing the lamp. ClickItem - * - * @param c - * @param id - */ - public static void rubLamp(Player c, int id) { - c.getPacketSender().sendMessage("You rub the lamp."); - c.getPacketSender().showInterface(SKILL_MENU); - } - -} diff --git a/2006Scape Server/src/main/java/com/rs2/game/npcs/NpcActions.java b/2006Scape Server/src/main/java/com/rs2/game/npcs/NpcActions.java index ee2eb581..f0e735d8 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/npcs/NpcActions.java +++ b/2006Scape Server/src/main/java/com/rs2/game/npcs/NpcActions.java @@ -704,9 +704,6 @@ public class NpcActions { case TRAMP_641: player.getDialogueHandler().sendDialogues(11, npcType); break; - case FREAKY_FORESTER: - player.getDialogueHandler().sendDialogues(2, npcType); - break; case BARTENDER: player.getDialogueHandler().sendDialogues(19, npcType); break; diff --git a/2006Scape Server/src/main/java/com/rs2/game/npcs/NpcHandler.java b/2006Scape Server/src/main/java/com/rs2/game/npcs/NpcHandler.java index bd6da9ba..febb1770 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/npcs/NpcHandler.java +++ b/2006Scape Server/src/main/java/com/rs2/game/npcs/NpcHandler.java @@ -7,6 +7,8 @@ import com.rs2.GameEngine; import com.rs2.event.CycleEvent; import com.rs2.event.CycleEventContainer; import com.rs2.event.CycleEventHandler; +import com.rs2.event.impl.NpcDeathEvent; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.StaticItemList; import com.rs2.game.content.combat.AttackType; import com.rs2.game.content.combat.CombatConstants; @@ -16,9 +18,6 @@ import com.rs2.game.content.combat.npcs.NpcEmotes; import com.rs2.game.content.minigames.FightCaves; import com.rs2.game.content.minigames.PestControl; import com.rs2.game.content.music.sound.CombatSounds; -import com.rs2.game.content.randomevents.FreakyForester; -import com.rs2.game.content.randomevents.RandomEventHandler; -import com.rs2.game.content.randomevents.RiverTroll; import com.rs2.game.npcs.drops.ItemDrop; import com.rs2.game.npcs.drops.NPCDropsHandler; import com.rs2.game.npcs.impl.Pets; @@ -260,6 +259,12 @@ public class NpcHandler { public static void spawnNpc(Player client, int npcType, int x, int y, int heightLevel, int WalkingType, int HP, int maxHit, int attack, int defence, boolean attackPlayer, boolean headIcon) { + spawnNpcReturn(client, npcType, x, y, heightLevel, WalkingType, HP, maxHit, attack, defence, attackPlayer, headIcon); + } + + public static Npc spawnNpcReturn(Player client, int npcType, int x, int y, + int heightLevel, int WalkingType, int HP, int maxHit, int attack, + int defence, boolean attackPlayer, boolean headIcon) { // first, search for a free slot int slot = -1; for (int i = 1; i < MAX_NPCS; i++) { @@ -270,7 +275,7 @@ public class NpcHandler { } if (slot == -1) { // System.out.println("No Free Slot"); - return; // no free slot found + return null; // no free slot found } Npc newNPC = new Npc(slot, npcType); newNPC.absX = x; @@ -304,6 +309,7 @@ public class NpcHandler { } } npcs[slot] = newNPC; + return newNPC; } public void spawnNpc2(int npcType, int x, int y, int heightLevel, int WalkingType, int HP, int maxHit, int attack, int defence, boolean attackPlayer) { @@ -594,7 +600,7 @@ public class NpcHandler { npcs[i].underAttackBy = 0; } - if (Player.postNpcTick(i, npcs[i])) { + if (Player.postNpcTick(i, npcs[i]) || npcs[i] == null) { continue; } @@ -846,26 +852,11 @@ public class NpcHandler { player.getPacketSender().sendMessage( "You have defeated the tree spirit."); } - if (npcs[i].npcType > BAT && npcs[i].npcType < ZOMBIE_419) { - player.golemSpawned = false; - } - if (npcs[i].npcType == COUNT_DRAYNOR && player.vampSlayer == 2) { + if (npcs[i].npcType == COUNT_DRAYNOR && player != null && player.vampSlayer == 2) { com.rs2.game.content.quests.QuestRewards.vampFinish(player); } - if (npcs[i].npcType > BIG_FISH && npcs[i].npcType < COW_397) { - RiverTroll.hasRiverTroll = false; - } - if (npcs[i].npcType > ROCK_GOLEM_418 && npcs[i].npcType < SHADE) { - player.zombieSpawned = false; - } - if (npcs[i].npcType > ZOMBIE_424 && npcs[i].npcType < WATCHMAN_431) { - player.shadeSpawned = false; - } - if (npcs[i].npcType > CAPN_IZZY_NOBEARD && npcs[i].npcType < GOBLIN_444) { - player.treeSpiritSpawned = false; - } - if (npcs[i].npcType > PHEASANT_2462 && npcs[i].npcType < FROG_2469) { - player.chickenSpawned = false; + if (player != null) { + player.post(new NpcDeathEvent(npcs[i].npcType, i, npcs[i])); } npcs[i].absX = npcs[i].makeX; npcs[i].absY = npcs[i].makeY; @@ -1057,19 +1048,9 @@ public class NpcHandler { } switch (npcs[i].npcType) { case PHEASANT: - FreakyForester.killedPheasant(c, 0); - GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId); - break; case PHEASANT_2460: - FreakyForester.killedPheasant(c, 1); - GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId); - break; case PHEASANT_2461: - FreakyForester.killedPheasant(c, 2); - GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId); - break; case PHEASANT_2462: - FreakyForester.killedPheasant(c, 3); GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId); break; case SKELETON_92: @@ -1146,7 +1127,7 @@ public class NpcHandler { public void resetEvent(int i) { Player c = (Client) PlayerHandler.players[npcs[i].killedBy]; if (c != null) { - RandomEventHandler.addRandom(c); + c.post(new RandomActionEvent("general")); } } diff --git a/2006Scape Server/src/main/java/com/rs2/game/objects/ObjectDefaults.java b/2006Scape Server/src/main/java/com/rs2/game/objects/ObjectDefaults.java index 7aef32c3..2303ab12 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/objects/ObjectDefaults.java +++ b/2006Scape Server/src/main/java/com/rs2/game/objects/ObjectDefaults.java @@ -2,7 +2,9 @@ package com.rs2.game.objects; import org.apollo.cache.def.ObjectDefinition; +import com.rs2.GameEngine; import com.rs2.game.players.Player; +import com.rs2.world.clip.Region; /** * ObjectDefaults @@ -65,6 +67,14 @@ public class ObjectDefaults { }; public static int getObjectFace(Player player, int objectType) { + Objects regionObj = Region.getObject(objectType, player.objectX, player.objectY, player.getH()); + if (regionObj != null) { + return regionObj.getObjectFace(); + } + Objects globalObj = GameEngine.objectHandler.objectExists(player.objectX, player.objectY, player.getH()); + if (globalObj != null && globalObj.getObjectId() == objectType) { + return globalObj.getObjectFace(); + } //default face int face = SOUTH; for (final int[] element : GET_FACE) { diff --git a/2006Scape Server/src/main/java/com/rs2/game/objects/ObjectsActions.java b/2006Scape Server/src/main/java/com/rs2/game/objects/ObjectsActions.java index 04b65a59..0b306be9 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/objects/ObjectsActions.java +++ b/2006Scape Server/src/main/java/com/rs2/game/objects/ObjectsActions.java @@ -13,7 +13,6 @@ import com.rs2.game.content.minigames.castlewars.CastleWarObjects; import com.rs2.game.content.minigames.castlewars.CastleWars; import com.rs2.game.content.quests.QuestRewards; import com.rs2.game.content.random.PartyRoom; -import com.rs2.game.content.randomevents.FreakyForester; import com.rs2.game.content.skills.agility.AgilityShortcut; import com.rs2.game.content.skills.core.Mining; import com.rs2.game.content.skills.crafting.Spinning; @@ -2245,14 +2244,6 @@ public class ObjectsActions { player.getDialogueHandler().sendStatement("You arrive safely."); break; - case 8972: - if (!player.canLeaveArea) { - player.getDialogueHandler().sendDialogues(3, 2458); - } else { - FreakyForester.leaveArea(player); - } - break; - case 1765://down if (player.inWild() && player.absX > 3015 && player.absX < 3019) { player.getPlayerAssistant().movePlayer(3067, 10256, 0); diff --git a/2006Scape Server/src/main/java/com/rs2/game/objects/impl/OpenObject.java b/2006Scape Server/src/main/java/com/rs2/game/objects/impl/OpenObject.java index d3373f4f..e5d8bfb1 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/objects/impl/OpenObject.java +++ b/2006Scape Server/src/main/java/com/rs2/game/objects/impl/OpenObject.java @@ -27,14 +27,30 @@ public class OpenObject { public static void interactObject(Player player, int objectType) { for (final int[] element : OBJECT_DATA) { + int newId = -1; if (objectType == element[0]) { - GameEngine.objectHandler.placeObject(new Objects(element[1], player.objectX, player.objectY, player.getH(), ObjectDefaults.getObjectFace(player, objectType), 10, 0)); - Region.addObject(element[1], player.objectX, player.objectY, player.getH(), ObjectDefaults.getObjectFace(player, objectType), 10, false); - player.startAnimation(832); + newId = element[1]; } else if (objectType == element[1]) { - GameEngine.objectHandler.placeObject(new Objects(element[0], player.objectX, player.objectY, player.getH(), ObjectDefaults.getObjectFace(player, objectType), 10, 0)); - Region.addObject(element[0], player.objectX, player.objectY, player.getH(), ObjectDefaults.getObjectFace(player, objectType), 10, false); + newId = element[0]; + } + if (newId != -1) { + int x = player.objectX; + int y = player.objectY; + int h = player.getH(); + int face = ObjectDefaults.getObjectFace(player, objectType); + Objects regionObj = Region.getObject(objectType, x, y, h); + int type = regionObj != null ? regionObj.objectType : 10; + Objects existing = GameEngine.objectHandler.objectExists(x, y, h); + if (existing != null) { + GameEngine.objectHandler.removeObject(existing); + } + Objects newObj = new Objects(newId, x, y, h, face, type, 0); + GameEngine.objectHandler.addObject(newObj); + GameEngine.objectHandler.placeObject(newObj); + Region.removeObject(objectType, x, y, h, type, face); + Region.addObject(newId, x, y, h, type, face, false); player.startAnimation(832); + return; } } } diff --git a/2006Scape Server/src/main/java/com/rs2/game/players/Player.java b/2006Scape Server/src/main/java/com/rs2/game/players/Player.java index 42dac7cb..5200c530 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/players/Player.java +++ b/2006Scape Server/src/main/java/com/rs2/game/players/Player.java @@ -950,9 +950,7 @@ public abstract class Player { } public void process() { - if (Boundary.isIn(this, Boundary.DESERT) && heightLevel == 0) { - DesertHeat.callHeat(this); - } + DesertHeat.callHeat(this); if (playerEnergy < 100 && System.currentTimeMillis() - lastIncrease >= getPlayerAssistant().raiseTimer()) { playerEnergy += 1; lastIncrease = System.currentTimeMillis(); @@ -1167,17 +1165,7 @@ public abstract class Player { * the sound plays. */ public void sendSound(int id, int volume, int delay) { - try { - outStream.createFrameVarSize(174); - outStream.writeWord(id); - outStream.writeByte(volume); - outStream.writeWord(delay); - updateRequired = true; - appearanceUpdateRequired = true; - outStream.endFrameVarSize(); - } catch (Exception e) { - e.printStackTrace(); - } + getPacketSender().sendSound(id, volume, delay); } /** @@ -1409,6 +1397,8 @@ public abstract class Player { public int miningAxe = -1, woodcuttingAxe = -1; + public int musicVolumeLevel = 0, soundVolumeLevel = 0; + public boolean initialized, musicOn = true, soundOn = true, luthas, playerIsCooking, disconnected, ruleAgreeButton, rebuildNPCList, isActive, isKicked, @@ -1425,22 +1415,21 @@ public abstract class Player { clickedSpinning, hasPaidBrim, playerStun, playerFletch, isWoodcutting, playerIsFiremaking, hasNpc, playerIsFishing, isOperate, below459 = true, splitChat, strongHold, village, needsNewTask, - canSpeak = true, ignoreFrog, ratdied2, + canSpeak = true, ratdied2, fishingWhirlPool, lostDuel, diedOnTut, storing, rope, rope2, canWalkTutorial, closeTutorialInterface, isCrafting, showedUnfire, showedFire, isPotCrafting, isFiremaking, playerIsFletching, stopPlayerPacket, spiritTree, isSmelting, isSmithing, hasPaid, canTeleport, magicCharge, clickedVamp, allowFading, otherBank, - recievedReward, poison, golemSpawned, zombieSpawned, shadeSpawned, - treeSpiritSpawned,leprechaunSpawned, chickenSpawned, clickedTree, filter = true, - stopPlayer, npcCanAttack = true, gliderOpen, hasSandwhichLady, + poison, leprechaunSpawned, clickedTree, filter = true, + stopPlayer, npcCanAttack = true, gliderOpen, isHarvesting, openDuel, killedJad, canHealersRespawn = true, playerIsBusy, miningRock, randomEventsEnabled, debugMode, clickToTele = false; public int votePoints, saveDelay, playerKilled, gertCat, restGhost, romeojuliet, runeMist, lostCity, vampSlayer, doricQuest, blackKnight, shieldArrav, - sheepShear, impsC, princeAli, randomActions, questVarpVersion = 0, + sheepShear, impsC, princeAli, questVarpVersion = 0, totalPlayerDamageDealt, killedBy, lastChatId = 1, privateChat, dialogueId, randomCoffin, newLocation, specEffect, specBarId, attackLevelReq, defenceLevelReq, strengthLevelReq, @@ -1568,13 +1557,7 @@ public abstract class Player { public boolean stopPlayerSkill; public int doAmount, addAmount; public int lastNpcClickIndex; - public boolean[] killedPheasant = new boolean[5]; - public boolean playerHasRandomEvent; - public boolean canLeaveArea; - - public int pieSelect = 0, getPheasent, kebabSelect = 0, breadID, - chocSelect = 0, bagelSelect = 0, triangleSandwich = 0, - squareSandwich = 0, breadSelect = 0; + public int breadID; public String properName; public int lastX, lastY; diff --git a/2006Scape Server/src/main/java/com/rs2/game/players/PlayerAssistant.java b/2006Scape Server/src/main/java/com/rs2/game/players/PlayerAssistant.java index c33d8406..5605594d 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/players/PlayerAssistant.java +++ b/2006Scape Server/src/main/java/com/rs2/game/players/PlayerAssistant.java @@ -16,7 +16,7 @@ import com.rs2.game.content.minigames.FightPits; import com.rs2.game.content.minigames.PestControl; import com.rs2.game.content.minigames.castlewars.CastleWars; import com.rs2.game.content.music.sound.SoundList; -import com.rs2.game.content.randomevents.RandomEventHandler; +import com.rs2.event.impl.RandomActionEvent; import com.rs2.game.content.skills.SkillData; import com.rs2.game.content.skills.SkillHandler; import com.rs2.game.items.DeprecatedItems; @@ -1220,7 +1220,7 @@ public class PlayerAssistant { addSkillXP(31, 6); player.getPacketSender().sendSound( SoundList.LOW_ALCHEMY, 100, 0); - RandomEventHandler.addRandom(player); + player.post(new RandomActionEvent("general")); refreshSkill(6); } break; @@ -1285,7 +1285,7 @@ public class PlayerAssistant { player.gfx100(MagicData.MAGIC_SPELLS[50][3]); player.alchDelay = System.currentTimeMillis(); player.getPacketSender().sendShowTab(6); - RandomEventHandler.addRandom(player); + player.post(new RandomActionEvent("general")); addSkillXP(65, 6); player.getPacketSender().sendSound( SoundList.HIGH_ALCHEMY, 100, 0); diff --git a/2006Scape Server/src/main/java/com/rs2/game/players/PlayerSave.java b/2006Scape Server/src/main/java/com/rs2/game/players/PlayerSave.java index 5c73c917..c3344b69 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/players/PlayerSave.java +++ b/2006Scape Server/src/main/java/com/rs2/game/players/PlayerSave.java @@ -158,7 +158,7 @@ public class PlayerSave { player.crystalBowArrowCount = Integer.parseInt(token2); break; case "randomActions": - player.randomActions = Integer.parseInt(token2); + player.getPluginData().putInt("randomevents", "randomActions", Integer.parseInt(token2)); break; case "debugMode": player.debugMode = Boolean.parseBoolean(token2); @@ -191,11 +191,20 @@ public class PlayerSave { player.recievedMask = Boolean.parseBoolean(token2); break; case "recievedReward": - player.recievedReward = Boolean.parseBoolean(token2); + player.getPluginData().putBoolean("randomevents", "foresterRewarded", Boolean.parseBoolean(token2)); break; case "splitChat": player.splitChat = Boolean.parseBoolean(token2); break; + case "mouseButton": + player.mouseButton = Boolean.parseBoolean(token2); + break; + case "chatEffects": + player.chatEffects = Boolean.parseBoolean(token2); + break; + case "acceptAid": + player.acceptAid = Boolean.parseBoolean(token2); + break; case "hasPaid": player.hasPaid = Boolean.parseBoolean(token2); break; @@ -214,9 +223,23 @@ public class PlayerSave { break; case "musicOn": player.musicOn = Boolean.parseBoolean(token2); + if (!player.musicOn) { + player.musicVolumeLevel = 4; + } + break; + case "musicVolume": + player.musicVolumeLevel = Math.max(0, Math.min(4, Integer.parseInt(token2))); + player.musicOn = player.musicVolumeLevel != 4; break; case "soundOn": player.soundOn = Boolean.parseBoolean(token2); + if (!player.soundOn) { + player.soundVolumeLevel = 4; + } + break; + case "soundVolume": + player.soundVolumeLevel = Math.max(0, Math.min(4, Integer.parseInt(token2))); + player.soundOn = player.soundVolumeLevel != 4; break; case "barrowsNpcs": player.barrowsNpcs[Integer.parseInt(token3[0])][1] = Integer.parseInt(token3[1]); @@ -409,9 +432,17 @@ public class PlayerSave { player.creationAddress = token2; break; case "music": - for (int j = 0; j < token3.length; j++) { + for (int j = 0; j < token3.length && j < player.getPlayList().unlocked.length; j++) { player.getPlayList().unlocked[j] = Boolean.parseBoolean(token3[j]); } + // Default-unlocked tracks in RS2 + player.getPlayList().unlocked[28] = true; + player.getPlayList().unlocked[92] = true; + player.getPlayList().unlocked[93] = true; + player.getPlayList().unlocked[94] = true; + player.getPlayList().unlocked[95] = true; + player.getPlayList().unlocked[204] = true; + player.getPlayList().unlocked[316] = true; break; case "void": for (int j = 0; j < token3.length; j++) { @@ -784,8 +815,6 @@ public class PlayerSave { characterfile.newLine(); characterfile.write("recievedMask = " + player.recievedMask); characterfile.newLine(); - characterfile.write("recievedReward = " + player.recievedReward); - characterfile.newLine(); characterfile.write("global-damage = " + player.globalDamageDealt); characterfile.newLine(); characterfile.write("brightness = " + player.brightness); @@ -808,6 +837,12 @@ public class PlayerSave { characterfile.newLine(); characterfile.write("splitChat = " + player.splitChat); characterfile.newLine(); + characterfile.write("mouseButton = " + player.mouseButton); + characterfile.newLine(); + characterfile.write("chatEffects = " + player.chatEffects); + characterfile.newLine(); + characterfile.write("acceptAid = " + player.acceptAid); + characterfile.newLine(); characterfile.write("canSpeak = " + player.canSpeak); characterfile.newLine(); for (int b = 0; b < player.barrowsNpcs.length; b++) { @@ -824,8 +859,6 @@ public class PlayerSave { } characterfile.write("music = " + music.trim()); characterfile.newLine(); - characterfile.write("randomActions = " + player.randomActions); - characterfile.newLine(); characterfile.write("blackMarks = " + player.blackMarks); characterfile.newLine(); characterfile.write("tutorial-progress = " + player.tutorialProgress); @@ -862,8 +895,12 @@ public class PlayerSave { characterfile.newLine(); characterfile.write("musicOn = " + player.musicOn); characterfile.newLine(); + characterfile.write("musicVolume = " + player.musicVolumeLevel); + characterfile.newLine(); characterfile.write("soundOn = " + player.soundOn); characterfile.newLine(); + characterfile.write("soundVolume = " + player.soundVolumeLevel); + characterfile.newLine(); characterfile.write("needsNewTask = " + player.needsNewTask); characterfile.newLine(); characterfile.write("luthas = " + player.luthas); diff --git a/2006Scape Server/src/main/java/com/rs2/game/shops/ShopAssistant.java b/2006Scape Server/src/main/java/com/rs2/game/shops/ShopAssistant.java index a6a27b9b..e1fc7c9e 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/shops/ShopAssistant.java +++ b/2006Scape Server/src/main/java/com/rs2/game/shops/ShopAssistant.java @@ -1,6 +1,7 @@ package com.rs2.game.shops; import com.rs2.Constants; +import com.rs2.event.impl.RandomActionEvent; import org.apollo.cache.def.ItemDefinition; import com.rs2.game.bots.BotHandler; @@ -37,6 +38,7 @@ public class ShopAssistant { player.shopId = ShopID; player.getPacketSender().sendFrame248(3824, 3822); player.getPacketSender().sendString(ShopHandler.shopName[ShopID], 3901); + player.post(new RandomActionEvent("general")); } public void updatePlayerShop() { diff --git a/2006Scape Server/src/main/java/com/rs2/game/shops/ShopHandler.java b/2006Scape Server/src/main/java/com/rs2/game/shops/ShopHandler.java index e0615e7e..7e579174 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/shops/ShopHandler.java +++ b/2006Scape Server/src/main/java/com/rs2/game/shops/ShopHandler.java @@ -68,32 +68,33 @@ public class ShopHandler { } public void process() { - boolean DidUpdate = false; for (int i = 1; i <= totalshops; i++) { if (shopBModifier[i] == 0 || shopSModifier[i] == 0) { continue; } + boolean shopUpdated = false; for (int j = 0; j < MAX_SHOP_ITEMS; j++) { if (shopItems[i][j] > 0) { if (shopItemsDelay[i][j] >= SHOW_DELAY) { - if (j <= shopItemsStandard[i] && shopItemsN[i][j] <= shopItemsSN[i][j]) { + if (j < shopItemsStandard[i] && shopItemsN[i][j] <= shopItemsSN[i][j]) { if (shopItemsN[i][j] < shopItemsSN[i][j] && System.currentTimeMillis() - shopItemsRestock[i][j] > restockTimeItem(shopItems[i][j])) { shopItemsN[i][j] += 1; - shopItemsDelay[i][j] = 1; shopItemsDelay[i][j] = 0; - DidUpdate = true; + shopUpdated = true; shopItemsRestock[i][j] = System.currentTimeMillis(); } } else if (shopItemsDelay[i][j] >= SPECIAL_DELAY) { DiscountItem(i, j); shopItemsDelay[i][j] = 0; - DidUpdate = true; + shopUpdated = true; } - refreshshop(i); } shopItemsDelay[i][j]++; } } + if (shopUpdated) { + refreshshop(i); + } } } @@ -114,6 +115,7 @@ public class ShopHandler { shopItems[shopID][ArrayID] = 0; shopItemsN[shopID][ArrayID] = 0; shopItemsDelay[shopID][ArrayID] = 0; + shopItemsRestock[shopID][ArrayID] = 0; } public void loadShops() { @@ -294,7 +296,12 @@ public class ShopHandler { item_id++; for (int j = 0; j < MAX_SHOP_ITEMS; j++) { if (shopItems[shop_id][j] == item_id) { + boolean wasAtOrAboveMax = shopItemsN[shop_id][j] >= shopItemsSN[shop_id][j]; shopItemsN[shop_id][j] -= amount; + if (wasAtOrAboveMax && shopItemsN[shop_id][j] < shopItemsSN[shop_id][j]) { + shopItemsRestock[shop_id][j] = System.currentTimeMillis(); + shopItemsDelay[shop_id][j] = 0; + } } } refreshshop(shop_id); diff --git a/2006Scape Server/src/main/java/com/rs2/game/shops/Shops.java b/2006Scape Server/src/main/java/com/rs2/game/shops/Shops.java index 1c030c4d..9b3b6c0a 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/shops/Shops.java +++ b/2006Scape Server/src/main/java/com/rs2/game/shops/Shops.java @@ -2,7 +2,6 @@ package com.rs2.game.shops; import java.util.HashMap; -import com.rs2.game.content.randomevents.RandomEventHandler; import com.rs2.game.players.Player; import static com.rs2.game.content.StaticNpcList.*; @@ -16,7 +15,7 @@ public class Shops { public enum Shop { SHOP1(DAVON, 2), SHOP2(LOWE, 3), SHOP3(HICKTON, 4), SHOP4(DALLDAV, 5), SHOP5(SQUIRE_3796, 6), SHOP6(BRIAN_1860, 7), SHOP7(BRIAN, 9), SHOP8(CANDLE_MAKER, 10), - SHOP9(WAYNE, 11), SHOP10(THESSALIA, 12), SHOP11(FANCY_DRESS_SHOP_OWNER, 13), SHOP12(ROMETTI, 14), + SHOP9(WAYNE, 11), SHOP11(FANCY_DRESS_SHOP_OWNER, 13), SHOP12(ROMETTI, 14), SHOP13(YRSA, 15), SHOP14(BARKER, 16), SHOP15(ORONWEN, 17), SHOP16(MIKE, 18), SHOP17(AGMUNDI, 19), SHOP18(VERMUNDI, 20), SHOP19(HUDO, 21), SHOP20(HECKEL_FUNCH, 22), SHOP21(FRENITA, 23), SHOP22(DOMMIK, 24), SHOP23(ROMMIK, 25), SHOP24(VANESSA, 26), @@ -98,7 +97,6 @@ public class Shops { return; if (npcClickId == shops.getNpc()) { c.getShopAssistant().openShop(shops.getShop()); - RandomEventHandler.addRandom(c); } } diff --git a/2006Scape Server/src/main/java/com/rs2/net/PacketSender.java b/2006Scape Server/src/main/java/com/rs2/net/PacketSender.java index d59a55dc..bf8aeba5 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/PacketSender.java +++ b/2006Scape Server/src/main/java/com/rs2/net/PacketSender.java @@ -3,6 +3,7 @@ package com.rs2.net; import java.text.DecimalFormat; import com.rs2.Connection; import com.rs2.Constants; +import com.rs2.game.content.music.Music; import com.rs2.GameEngine; import com.rs2.game.content.combat.magic.MagicTeleports; import com.rs2.game.content.quests.QuestAssistant; @@ -144,13 +145,10 @@ public class PacketSender { if (player.inWild()) { player.wildernessWarning = true; } - if (player.splitChat) { - player.getPacketSender().sendConfig(502, 1); - player.getPacketSender().sendConfig(287, 1); - } else { - player.getPacketSender().sendConfig(502, 0); - player.getPacketSender().sendConfig(287, 0); - } + player.getPacketSender().sendConfig(170, player.mouseButton ? 1 : 0); + player.getPacketSender().sendConfig(171, player.chatEffects ? 0 : 1); + player.getPacketSender().sendConfig(287, player.splitChat ? 1 : 0); + player.getPacketSender().sendConfig(427, player.acceptAid ? 1 : 0); if (player.isRunning2) { player.getPacketSender().sendConfig(504, 1); player.getPacketSender().sendConfig(173, 1); @@ -158,7 +156,12 @@ public class PacketSender { player.getPacketSender().sendConfig(504, 0); player.getPacketSender().sendConfig(173, 0); } - player.getPlayList().fixAllColors(); + player.getPacketSender().sendConfig(168, player.musicOn ? player.musicVolumeLevel : 4); + player.getPacketSender().sendConfig(169, player.soundOn ? player.soundVolumeLevel : 4); + player.getPlayList().sendMusicConfigs(); + if (Constants.SOUND) { + Music.playMusic(player); + } player.getPlayerAction().setAction(false); player.getPlayerAction().canWalk(true); player.getPlayerAssistant().handleWeaponStyle(); @@ -1118,11 +1121,14 @@ public class PacketSender { */ public PacketSender sendSong(int id) { - if (player.getOutStream() == null) + if (player == null || player.getOutStream() == null) return this; - if (player != null && id != -1) { + if (!player.musicOn && id != -1) + return this; + if (id != -1) { player.getOutStream().createFrame(74); player.getOutStream().writeWordBigEndian(id); + player.flushOutStream(); } return this; } @@ -1148,17 +1154,7 @@ public class PacketSender { */ public PacketSender sendSound(int id, int type, int delay, int volume) { - if (player.getOutStream() == null) - return this; - if (player != null && id != -1) { - player.getOutStream().createFrame(174); - player.getOutStream().writeWord(id); - player.getOutStream().writeByte(type); - player.getOutStream().writeWord(delay); - player.getOutStream().writeWord(volume); - player.flushOutStream(); - } - return this; + return sendSound(id, volume, delay); } /** diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ChangeRegions.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ChangeRegions.java index 5f6cce59..509afd7d 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ChangeRegions.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ChangeRegions.java @@ -15,7 +15,7 @@ public class ChangeRegions implements PacketType { @Override public void processPacket(Player player, Packet packet) { - if (Constants.SOUND && player.musicOn) { + if (Constants.SOUND) { Music.playMusic(player); } GameEngine.objectHandler.updateObjects(player);//testing diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickItem.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickItem.java index 9418ae84..db6fac25 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickItem.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickItem.java @@ -13,7 +13,6 @@ import com.rs2.game.content.skills.herblore.Herblore; import com.rs2.game.content.skills.prayer.Prayer; import com.rs2.game.content.skills.woodcutting.BirdNest; import com.rs2.game.items.DeprecatedItems; -import com.rs2.game.items.impl.ExperienceLamp; import com.rs2.game.items.impl.Flowers; import com.rs2.game.items.impl.GodBooks; import com.rs2.game.players.Player; @@ -141,11 +140,6 @@ public class ClickItem implements PacketType { case 1971: Kebabs.eat(player, itemSlot); break; - - case 2528: - case 4447: - ExperienceLamp.rubLamp(player, itemId); - break; case 2677: if (Constants.CLUES_ENABLED) { @@ -186,10 +180,6 @@ public class ClickItem implements PacketType { player.getPlayerAssistant().startTeleport(2661, 3310, 0, "modern"); break; - // case 2528: - // ExperienceLamp.showInterface(c); - // break; - case 5070: if (player.getItemAssistant().freeSlots() >= 2) { player.getPacketSender().sendMessage("You search the nest."); diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickNPC.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickNPC.java index 265cc4e2..c3f4f718 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickNPC.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickNPC.java @@ -240,7 +240,7 @@ public class ClickNPC implements PacketType { player.npcClickIndex = packet.readSignedWordBigEndian(); NpcInteraction.handle(player, 1, npc -> { player.getNpcs().firstClickNpc(player.npcType); - player.post(new NpcFirstClickEvent(player.npcType, player.npcClickIndex)); + player.post(new NpcFirstClickEvent(player.npcType, npc.npcId)); }); break; diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickingButtons.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickingButtons.java index 81d1d97f..0903cf98 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickingButtons.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ClickingButtons.java @@ -9,7 +9,6 @@ import com.rs2.game.content.combat.prayer.ActivatePrayers; import com.rs2.game.content.music.sound.SoundList; import com.rs2.game.content.quests.QuestAssistant; import com.rs2.game.content.random.PartyRoom; -import com.rs2.game.content.randomevents.SandwhichLady; import com.rs2.game.content.skills.cooking.Cooking; import com.rs2.game.content.skills.cooking.CookingTutorialIsland; import com.rs2.game.content.skills.cooking.DairyChurn; @@ -28,7 +27,6 @@ import com.rs2.game.dialogues.DialogueOptions; import com.rs2.game.items.DeprecatedItems; import com.rs2.game.items.GameItem; import com.rs2.game.items.impl.EnchantStaff; -import com.rs2.game.items.impl.ExperienceLamp; import com.rs2.game.objects.impl.Climbing; import com.rs2.game.players.Client; import com.rs2.game.players.Player; @@ -65,10 +63,8 @@ public class ClickingButtons implements PacketType { QuestAssistant.questButtons(player, actionButtonId); LogCutting.handleClick(player, actionButtonId); Smelting.getBar(player, actionButtonId); - ExperienceLamp.buttons(player, actionButtonId); Herblore.handleHerbloreButtons(player, actionButtonId); LeatherMaking.craftLeather(player, actionButtonId); - SandwhichLady.handleOptions(player, actionButtonId); SilverCrafting.makeSilver(player, actionButtonId, 0); Climbing.handleLadderButtons(player, actionButtonId); Specials.specialClicking(player, actionButtonId); @@ -79,9 +75,7 @@ public class ClickingButtons implements PacketType { if (EnchantStaff.staffButtons(player, actionButtonId)) { return; } - if (player.musicOn) { - player.getPlayList().handleButton(actionButtonId); - } + player.getPlayList().handleButton(actionButtonId); for (tanningData t : tanningData.values()) { if (actionButtonId == t.getButtonId(actionButtonId)) { @@ -1360,40 +1354,6 @@ public class ClickingButtons implements PacketType { "Waiting for other player...", 3535); } - break; - /* Player Options */ - case 74176: - if (!player.mouseButton) { - player.mouseButton = true; - player.getPacketSender().sendConfig(500, 1); - player.getPacketSender().sendConfig(170, 1); - } else if (player.mouseButton) { - player.mouseButton = false; - player.getPacketSender().sendConfig(500, 0); - player.getPacketSender().sendConfig(170, 0); - } - break; - case 74180: - if (!player.chatEffects) { - player.chatEffects = true; - player.getPacketSender().sendConfig(501, 1); - player.getPacketSender().sendConfig(171, 0); - } else { - player.chatEffects = false; - player.getPacketSender().sendConfig(501, 0); - player.getPacketSender().sendConfig(171, 1); - } - break; - case 74188: - if (!player.acceptAid) { - player.acceptAid = true; - player.getPacketSender().sendConfig(503, 1); - player.getPacketSender().sendConfig(427, 1); - } else { - player.acceptAid = false; - player.getPacketSender().sendConfig(503, 0); - player.getPacketSender().sendConfig(427, 0); - } break; case 74192: if (!player.isRunning2) { diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java index 23cd0d91..98d1827c 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java @@ -468,12 +468,6 @@ public class Commands implements PacketType { } player.getPacketSender().showInterface(8134); break; - case "randomtoggle": - case "togglerandom": - case "random": - player.randomEventsEnabled = !player.randomEventsEnabled; - player.getPacketSender().sendMessage("You will " + (player.randomEventsEnabled ? "now" : "no longer") + " receieve random events."); - break; case "debug": case "debugmode": player.debugMode = !player.debugMode; diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ItemOnGroundItem.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ItemOnGroundItem.java index 791af92e..c34e430a 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ItemOnGroundItem.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ItemOnGroundItem.java @@ -32,8 +32,8 @@ public class ItemOnGroundItem implements PacketType { player.endCurrentTask(); - boolean reached = player.goodDistance(player.getX(), player.getY(), gItemX, gItemY, 1) - && (player.getX() == gItemX && player.getY() == gItemY || Region.canReachNpcMelee(player.getX(), player.getY(), player.heightLevel, gItemX, gItemY, 1)); + final boolean requiresSameTile = isFiremakingItem(itemUsed); + boolean reached = isInRange(player, gItemX, gItemY, requiresSameTile); if (reached) { handleItemOnGround(player, itemUsed, groundItem, gItemX, gItemY); return; @@ -50,9 +50,7 @@ public class ItemOnGroundItem implements PacketType { container.stop(); return; } - boolean inRange = player.goodDistance(player.getX(), player.getY(), gItemX, gItemY, 1) - && (player.getX() == gItemX && player.getY() == gItemY || Region.canReachNpcMelee(player.getX(), player.getY(), player.heightLevel, gItemX, gItemY, 1)); - if (inRange) { + if (isInRange(player, gItemX, gItemY, requiresSameTile)) { player.stopMovement(); handleItemOnGround(player, itemUsed, groundItem, gItemX, gItemY); container.stop(); @@ -70,6 +68,20 @@ public class ItemOnGroundItem implements PacketType { }, 1); } + private static boolean isFiremakingItem(int itemId) { + return itemId == TINDERBOX || itemId == BLUE_FIRELIGHTER + || itemId == GREEN_FIRELIGHTER || itemId == RED_FIRELIGHTER; + } + + private static boolean isInRange(Player player, int gItemX, int gItemY, boolean requiresSameTile) { + if (requiresSameTile) { + return player.getX() == gItemX && player.getY() == gItemY; + } + return player.goodDistance(player.getX(), player.getY(), gItemX, gItemY, 1) + && (player.getX() == gItemX && player.getY() == gItemY + || Region.canReachNpcMelee(player.getX(), player.getY(), player.heightLevel, gItemX, gItemY, 1)); + } + private void handleItemOnGround(Player player, int itemUsed, int groundItem, int gItemX, int gItemY) { switch (itemUsed) { case TINDERBOX: diff --git a/2006Scape Server/src/main/java/com/rs2/world/clip/Region.java b/2006Scape Server/src/main/java/com/rs2/world/clip/Region.java index bbfe7494..8eabad7a 100644 --- a/2006Scape Server/src/main/java/com/rs2/world/clip/Region.java +++ b/2006Scape Server/src/main/java/com/rs2/world/clip/Region.java @@ -97,6 +97,24 @@ public class Region { return false; } + /** + * Returns true if a static scenery object (type >= 9, excluding ground decorations) + * occupies the given tile. + */ + public static boolean hasSceneryObject(int x, int y, int z) { + Region r = getRegion(x, y); + if (r == null) { + return false; + } + for (Objects o : r.realObjects) { + if (o.objectX == x && o.objectY == y && o.objectHeight == z + && o.objectType >= 9 && o.objectType != 22) { + return true; + } + } + return false; + } + private void addClip(int x, int y, int height, int shift) { int regionAbsX = (id >> 8) * 64; int regionAbsY = (id & 0xff) * 64; diff --git a/pom.xml b/pom.xml index 801afa0b..734dd4ea 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,11 @@ pom 1.0 + + UTF-8 + UTF-8 + + 2006Scape Client 2006Scape Server