Repository reorganisation

Unified kotlin and java into just src/main
Unified the rs09 and core packages
Took all content out of the core package, and placed it into the new content package
Reorganised all source code relating to content to be easier to find and explore
This commit is contained in:
Ceikry
2023-01-26 13:59:28 +00:00
committed by Ryan
parent e4b799c44a
commit a100affda2
3156 changed files with 24205 additions and 30585 deletions
@@ -0,0 +1,126 @@
package content.global.skill.fishing;
import core.game.node.item.Item;
import java.util.HashMap;
/**
* Represents a type of fish to catch.
* @author ceikry
*/
public enum Fish {
CRAYFISH(new Item(13435),1, 10, 0.15, 0.5),
SHRIMP(new Item(317), 1, 10, 0.191, 0.5),
SARDINE(new Item(327), 5, 20, 0.148, 0.374),
KARAMBWANJI(new Item(3150), 5, 5, 0.4, 0.98),
HERRING(new Item(345), 10, 30, 0.129, 0.504),
ANCHOVIE(new Item(321), 15, 40, 0.098, 0.5),
MACKEREL(new Item(353), 16, 20, 0.055, 0.258),
TROUT(new Item(335), 20, 50, 0.246, 0.468),
COD(new Item(341), 23, 45, 0.063, 0.219),
PIKE(new Item(349), 25, 60, 0.14, 0.379),
SLIMY_EEL(new Item(3379), 28, 65, 0.117, 0.216),
SALMON(new Item(331), 30, 70, 0.156, 0.378),
FROG_SPAWN(new Item(5004), 33, 75, 0.164, 0.379),
TUNA(new Item(359), 35, 80, 0.109, 0.205),
RAINBOW_FISH(new Item(10138), 38, 80, 0.113, 0.254),
CAVE_EEL(new Item(5001), 38, 80, 0.145, 0.316),
LOBSTER(new Item(377), 40, 90, 0.16, 0.375),
BASS(new Item(363), 46, 100, 0.078, 0.16),
SWORDFISH(new Item(371), 50, 100, 0.105, 0.191),
LAVA_EEL(new Item(2148), 53, 30, 0.227, 0.379),
MONKFISH(new Item(7944), 62, 120, 0.293, 0.356),
KARAMBWAN(new Item(3142), 65, 105, 0.414, 0.629),
SHARK(new Item(383), 76, 110, 0.121, 0.16),
SEA_TURTLE(new Item(395), 79, 38, 0.0, 0.0),
MANTA_RAY(new Item(389), 81, 46, 0.0, 0.0),
SEAWEED(new Item(401), 16, 1, 0.63, 0.219),
CASKET(new Item(405), 16, 10, 0.63, 0.219),
OYSTER(new Item(407), 16, 10, 0.63, 0.219);
/**
* Constructs a new {@code Fish} {@code Object}.
* @param item the <code>Item</code>
* @param level the level.
* @param experience the experience.
*/
Fish(final Item item, final int level, final double experience, final double lowChance, final double highChance, final int... npcs) {
this.item = item;
this.level = level;
this.experience = experience;
this.npcs = npcs;
// The chances are given in the table based on when the fish can first be caught.
// Linearly extrapolate the success chance at level 1.
// y = (x - x0) * ((y1 - y0) / (x1 - x0)) + y0
this.lowChance = (1 - (double)level)*((highChance - lowChance) / (99.0 - (double)level)) + lowChance;
this.highChance = highChance;
}
public static HashMap<Integer,Fish> fishMap = new HashMap<>();
static{
for(Fish fish : Fish.values()){
fishMap.putIfAbsent(fish.item.getId(),fish);
}
}
private final Item item;
/**
* Represents the required level to catch the {@link Fish}.
*/
private final int level;
/**
* Represents the experience gained from this fish.
*/
private final double experience;
private final double lowChance;
private final double highChance;
/**
* The npc ids that give this fish.
*/
private final int[] npcs;
/**
* Gets the fish.
* @param item the item.
* @return the fash.
*/
public static Fish forItem(Item item) {
return fishMap.get(item.getId());
}
/**
* @return the item.
*/
public Item getItem() {
return item;
}
/**
* @return the level.
*/
public int getLevel() {
return level;
}
/**
* @return the experience.
*/
public double getExperience() {
return experience;
}
/**
* Gets the npcs.
* @return the npcs
*/
public int[] getNpcs() {
return npcs;
}
public double getSuccessChance(int level) {
return ((double)level - 1.0)*((highChance - lowChance) / (99.0 - 1.0)) + lowChance;
}
}
@@ -0,0 +1,56 @@
package content.global.skill.fishing;
import core.game.world.map.Location;
import java.util.HashMap;
/**
* Fishing spot locations
* @author Ceikry
*/
public enum FishSpots {
CATHERBY(Location.create(2844, 3429, 0), Location.create(2839, 3431, 0), new Location(2836, 3431, 0), new Location(2837, 3431, 0), new Location(2838, 3431, 0), new Location(2839, 3431, 0), new Location(2840, 3431, 0), new Location(2844, 3429, 0), new Location(2845, 3429, 0), new Location(2846, 3429, 0), new Location(2853, 3423, 0), new Location(2854, 3423, 0), new Location(2855, 3423, 0), new Location(2859, 3426, 0), new Location(2860, 3426, 0)),
ENTRANA(new Location(2842, 3359, 0), new Location(2843, 3359, 0), new Location(2844, 3359, 0), new Location(2847, 3361, 0), new Location(2848, 3361, 0), new Location(2849, 3361, 0), new Location(2850, 3361, 0)),
ENTRANA_PLATFORM(new Location(2879, 3334, 0), new Location(2879, 3335, 0), new Location(2879, 3338, 0), new Location(2879, 3339, 0), new Location(2877, 3342, 0), new Location(2876, 3342, 0), new Location(2875, 3342, 0), new Location(2875, 3331, 0), new Location(2876, 3331, 0), new Location(2877, 3331, 0)),
SEERS(new Location(2714, 3533, 0), new Location(2714, 3532, 0), new Location(2726, 3524, 0), new Location(2727, 3524, 0), new Location(2728, 3524, 0)),
DRAYNOR(new Location(3085, 3230, 0), new Location(3086, 3227, 0)),
BARBARIAN(new Location(3110, 3432, 0), new Location(3110, 3433, 0), new Location(3110, 3434, 0), Location.create(3104, 3425, 0), Location.create(3104, 3424, 0)),
LUMBRIDGE(new Location(3239, 3243, 0), new Location(3239, 3241, 0), new Location(3239, 3242, 0), Location.create(3238, 3251, 0), Location.create(3238, 3252, 0), Location.create(3238, 3253, 0)),
LUMBRIDGE_SWAMP(Location.create(3242, 3143, 0), Location.create(3242, 3148, 0), Location.create(3241, 3148, 0), Location.create(3240, 3147, 0), Location.create(3240, 3146, 0), Location.create(3244, 3150, 0), Location.create(3245, 3152, 0), Location.create(3246, 3155, 0), Location.create(3246, 3156, 0), new Location(3239, 3241, 0)),
LUMBRIDGE_MARSH(Location.create(3169, 3266, 0), Location.create(3168, 3266, 0), Location.create(3174, 3274, 0), Location.create(3173, 3274, 0)),
ALKHARID(new Location(3267, 3148, 0), new Location(3268, 3147, 0), new Location(3276, 3140, 0), new Location(3275, 3140, 0)),
FISHING_GUILD(new Location(2612, 3411, 0), new Location(2602, 3423, 0), new Location(2602, 3411, 0), new Location(2602, 3412, 0), new Location(2602, 3414, 0), new Location(2602, 3415, 0), new Location(2603, 3417, 0), new Location(2604, 3417, 0), new Location(2605, 3416, 0), new Location(2606, 3416, 0), new Location(2607, 3416, 0), new Location(2608, 3416, 0), new Location(2609, 3416, 0), new Location(2610, 3416, 0), new Location(2611, 3416, 0), new Location(2612, 3415, 0), new Location(2612, 3414, 0), new Location(2607, 3410, 0), new Location(2606, 3410, 0), new Location(2605, 3410, 0), new Location(2599, 3419, 0), new Location(2600, 3419, 0), new Location(2602, 3419, 0), new Location(2603, 3419, 0), new Location(2604, 3419, 0), new Location(2605, 3420, 0), new Location(2605, 3421, 0), new Location(2604, 3422, 0), new Location(2603, 3422, 0), new Location(2602, 3422, 0), new Location(2601, 3422, 0), new Location(2605, 3424, 0), new Location(2605, 3425, 0), new Location(2602, 3426, 0), new Location(2603, 3426, 0), new Location(2604, 3426, 0)),
GNOME(new Location(2388, 3424, 0), new Location(2390, 3422, 0), new Location(2391, 3421, 0), new Location(2382, 3413, 0), new Location(2382, 3414, 0), new Location(2382, 3415, 0)), CASTLEWAR(new Location(2465, 3156, 0), new Location(2464, 3155, 0), new Location(2468, 3157, 0), new Location(2469, 3157, 0), new Location(2471, 3158, 0), new Location(2472, 3156, 0), new Location(2462, 3145, 0), new Location(2461, 3150, 0), new Location(2461, 3151, 0)), SHILO(new Location(2460, 3144, 0), new Location(2461, 3150, 0), new Location(2461, 3151, 0), new Location(2853, 2977, 0), new Location(2854, 2977, 0), new Location(2855, 2977, 0), new Location(2856, 2977, 0), new Location(2858, 2976, 0), new Location(2859, 2976, 0), new Location(2860, 2976, 0), new Location(2863, 2975, 0), new Location(2863, 2975, 0), new Location(2864, 2975, 0), new Location(2865, 2972, 0), new Location(2860, 2972, 0), new Location(2855, 2974, 0), new Location(2852, 2973, 0)), KARAMJA(new Location(2923, 3178, 0), new Location(2923, 3179, 0), new Location(2923, 3180, 0), new Location(2924, 3181, 0), new Location(2925, 3181, 0), new Location(2926, 3180, 0), new Location(2926, 3179, 0), new Location(2926, 3178, 0), new Location(2926, 3177, 0), new Location(2926, 3176, 0)), DONATOR_ISLAND(Location.create(159, 41, 0), Location.create(160, 41, 0), Location.create(161, 41, 0), Location.create(162, 41, 0), Location.create(162, 30, 0)),
PISCATORIS(Location.create(2341, 3702, 0), Location.create(2342, 3702, 0), Location.create(2343, 3702, 0), Location.create(2344, 3702, 0), Location.create(2345, 3702, 0), Location.create(2346, 3702, 0), Location.create(2347, 3702, 0), Location.create(2349, 3702, 0), Location.create(2352, 3703, 0)),
TUTORIAL_ISLAND(Location.create(3101,3092, 0)),
WILDERNESS_ARENA(Location.create(3187, 3927, 0),Location.create(3185, 3926, 0),Location.create(3183, 3926, 0), Location.create(3181, 3926, 0));
FishSpots(final Location... locations) {
this.locations = locations;
}
private final Location[] locations;
public Location[] getLocations() {
return locations;
}
public static HashMap<Location,FishSpots> locationMap = new HashMap<>();
static{
FishSpots[] spots = values();
int spotsLength = spots.length;
for(int x = 0; x < spotsLength; x++){
Location[] locations = spots[x].locations;
int locationsLength = locations.length;
for(int y = 0; y < locationsLength; y++){
locationMap.putIfAbsent(locations[y],spots[x]);
}
}
}
//statically gets the fishing spot (loops suck btw)
public static FishSpots forLocation(Location loc) {
return locationMap.get(loc);
}
}
@@ -0,0 +1,103 @@
package content.global.skill.fishing;
import core.game.node.entity.npc.AbstractNPC;
import core.game.world.GameWorld;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.plugin.Initializable;
import core.tools.RandomFunction;
/**
* Represents the fishing npc.
* @author Vexia
*
*/
@Initializable
public final class FishingNPC extends AbstractNPC {
/**
* Represents the fishing spot.
*/
private FishSpots spot;
/**
* Represents the delay of switching.
*/
private int switchDelay;
/**
* Constructs a new {@code FishingNPC} {@code Object}.
*/
public FishingNPC() {
super(0, null);
spot = null;
}
/**
* Constructs a new {@code FishingNPC} {@code Object}.
* @param id the id.
* @param location the location.
*/
public FishingNPC(int id, Location location) {
super(id, location, false);
switchDelay = getRandomDelay();
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return new FishingNPC(id, location);
}
@Override
public void handleTickActions() {
if (spot == null) {
return;
}
if (switchDelay < GameWorld.getTicks()) {
moveSpot();
}
}
@Override
public void init() {
super.init();
spot = FishSpots.forLocation(getLocation());
}
/**
* Method used to move a spot.
*/
public void moveSpot() {
if (spot == null) {
if (isInvisible()) {
setInvisible(false);
} else {
setInvisible(true);
}
switchDelay = GameWorld.getTicks() + RandomFunction.random(200, 390);
return;
}
if (spot == FishSpots.TUTORIAL_ISLAND) {
return;
}
Location rand = spot.getLocations()[RandomFunction.random(spot.getLocations().length)];
if (RegionManager.getLocalNpcs(rand, 0).size() == 0) {
getProperties().setTeleportLocation(rand);
}
switchDelay = GameWorld.getTicks() + getRandomDelay();
}
/**
* Gets the random delay.
* @return the delay.
*/
private int getRandomDelay() {
return RandomFunction.random(200, 390);
}
@Override
public int[] getIds() {
return new int[] { 316, 319, 320, 323, 325, 326, 327, 330, 332, 404, 952, 1174, 1175, 1331, 2067, 2068, 2724, 4908, 5748, 5749, 7045, 313, 322, 334, 406, 1191, 1333, 1405, 1406, 3574, 3575, 3848, 3849, 5471, 7044, 233, 234, 235, 236, 309, 310, 311, 314, 315, 317, 318, 328, 329, 331, 403, 800, 927, 1189, 1190, 1236, 1237, 1238, 3019, 7636, 312, 321, 324, 333, 405, 1332, 1399, 3804, 5470, 7046 };
}
}
@@ -0,0 +1,213 @@
package content.global.skill.fishing;
import core.game.container.Container;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.game.world.update.flag.context.Animation;
import core.tools.RandomFunction;
import org.rs09.consts.Items;
import java.util.Arrays;
import java.util.HashMap;
/**
* Represents a fishing option.
* @author Emperor
*/
public enum FishingOption {
CRAYFISH_CAGE(new Item(13431), 1, Animation.create(619), null, "cage", Fish.CRAYFISH),
SMALL_NET(new Item(303), 1, Animation.create(621), null, "net", Fish.SHRIMP, Fish.ANCHOVIE),
BAIT(new Item(307), 5, Animation.create(622), new Item[]{new Item(313)}, "bait", Fish.SARDINE, Fish.HERRING),
LURE(new Item(309), 20, new Animation(622), new Item[]{new Item(Items.FEATHER_314), new Item(Items.STRIPY_FEATHER_10087)}, "lure", Fish.TROUT, Fish.SALMON, Fish.RAINBOW_FISH),
L_BAIT(new Item(307), 25, Animation.create(622), new Item[]{new Item(313)}, "bait", Fish.PIKE),
CAGE(new Item(301), 40, Animation.create(619), null, "cage", Fish.LOBSTER),
HARPOON(new Item(311), 35, Animation.create(618), null, "harpoon", Fish.TUNA, Fish.SWORDFISH),
BARB_HARPOON(new Item(10129), 35, Animation.create(618), null, "harpoon", Fish.TUNA, Fish.SWORDFISH),
BIG_NET(new Item(305), 16, Animation.create(620), null, "net", Fish.MACKEREL, Fish.COD, Fish.BASS, Fish.SEAWEED),
N_HARPOON(new Item(311), 76, Animation.create(618), null, "harpoon", Fish.SHARK),
H_NET(new Item(303), 62, Animation.create(621), null, "net", Fish.MONKFISH),
MORTMYRE_ROD(new Item(307), 5, Animation.create(622), new Item[]{new Item(313)},"bait", Fish.SLIMY_EEL),
LUMBDSWAMP_ROD(new Item(307), 5, Animation.create(622), new Item[]{new Item(313)}, "bait", Fish.SLIMY_EEL, Fish.FROG_SPAWN),
KBWANJI_NET(new Item(Items.SMALL_FISHING_NET_303), 5, Animation.create(621), null, "net", Fish.KARAMBWANJI),
KARAMBWAN_VES(new Item(Items.KARAMBWAN_VESSEL_3157), 65, Animation.create(1193), new Item[]{new Item(Items.RAW_KARAMBWANJI_3150)}, "fish", Fish.KARAMBWAN),
OILY_FISHING_ROD(new Item(Items.OILY_FISHING_ROD_1585), 53, Animation.create(622), new Item[]{new Item(313)}, "bait", Fish.LAVA_EEL);
public static final HashMap<String,FishingOption> nameMap = new HashMap<>();
static{
for(FishingOption option : FishingOption.values()){
nameMap.putIfAbsent(option.name,option);
}
}
public static FishingOption forName(String name){
return nameMap.get(name);
}
/**
* The tool required.
*/
private final Item tool;
/**
* The fishing level required.
*/
private final int level;
/**
* The fishing animation.
*/
private final Animation animation;
/**
* The bait.
*/
private final Item[] bait;
/**
* The option name.
*/
private final String name;
/**
* The fish to catch.
*/
private final Fish[] fish;
/**
* Constructs a new {@code FishingOption} {@code Object}.
* @param tool The tool needed.
* @param level The fishing level required.
* @param animation The animation.
* @param fish The fish to catch.
*/
FishingOption(Item tool, int level, Animation animation, Item[] bait, String name, Fish... fish) {
this.tool = tool;
this.level = level;
this.animation = animation;
this.bait = bait;
this.name = name;
Arrays.sort(fish, (x, y) -> y.getLevel() - x.getLevel());
this.fish = fish;
}
/**
* Method used to get a random {@link Fish}.
* @return the {@link Fish}.
*/
public Fish rollFish(final Player player) {
if (this == BIG_NET) {
switch (RandomFunction.randomize(100)) {
case 0:
return Fish.OYSTER;
case 50:
return Fish.CASKET;
case 90:
return Fish.SEAWEED;
}
}
int visibleLevel = player.getSkills().getLevel(Skills.FISHING);
int invisibleLevel = visibleLevel + player.getFamiliarManager().getBoost(Skills.FISHING);
for(Fish f : fish) {
if(f.getLevel() > player.getSkills().getLevel(Skills.FISHING)) {
continue;
}
if(this == LURE && (player.getInventory().contains(Items.STRIPY_FEATHER_10087, 1) != (f == Fish.RAINBOW_FISH))) {
continue;
}
double chance = f.getSuccessChance(invisibleLevel);
//System.out.printf("rollFish: %s %s %s %s %s\n", player.getName(), f.getItem().getName(), f.getLowChance(), f.getHighChance(), chance);
if(RandomFunction.random(0.0, 1.0) < chance) {
return f;
}
}
return null;
}
/**
* Gets the start message.
* @return The start message.
*/
public String getStartMessage() {
if (name.equals("net")) {
return "You cast out your net...";
}
return "You attempt to catch a fish.";
}
/**
* Gets the tool.
* @return The tool.
*/
public Item getTool() {
return tool;
}
/**
* Gets the level.
* @return The level.
*/
public int getLevel() {
return level;
}
/**
* Gets the animation.
* @return The animation.
*/
public Animation getAnimation() {
return animation;
}
public String getBaitName() {
if(bait != null && bait.length > 0) {
return bait[0].getName();
} else {
return "null";
}
}
public boolean hasBait(Container inventory) {
if(bait == null) {
return true;
} else {
boolean any_bait = false;
for(Item b : bait) {
any_bait = any_bait || inventory.containsItem(b);
}
return any_bait;
}
}
public boolean removeBait(Container inventory) {
if(bait == null) {
return true;
} else {
// Remove more specific bait (later in the list) first.
for(int i = bait.length; i > 0; i--) {
if(inventory.remove(bait[i-1])) {
return true;
}
}
return false;
}
}
/**
* Gets the name.
* @return The name.
*/
public String getName() {
return name;
}
/**
* Gets the fish.
* @return The fish.
*/
public Fish[] getFish() {
return fish;
}
}
@@ -0,0 +1,82 @@
package content.global.skill.fishing;
import java.util.HashMap;
/**
* Represents a fishing spot.
* @author ceikry
*/
public enum FishingSpot {
NET_BAIT(new int[] { 952, 316, 319, 320, 323, 325, 326, 327, 330, 332, 404, 1331, 2724, 4908, 7045 }, FishingOption.SMALL_NET, FishingOption.BAIT),
LURE_BAIT(new int[] { 309, 310, 311, 314, 315, 317, 318, 328, 329, 331, 403, 927, 1189, 1190, 3019 }, FishingOption.LURE, FishingOption.L_BAIT),
CAGE_HARPOON(new int[] { 312, 321, 324, 333, 405, 1332, 1399, 3804, 5470, 7046}, FishingOption.CAGE, FishingOption.HARPOON),
NET_HARPOON(new int[] { 313, 322, 334, 406, 1191, 1333, 1405, 1406, 3574, 3575, 5471, 7044 }, FishingOption.BIG_NET, FishingOption.N_HARPOON),
HARPOON_NET(new int[] { 3848, 3849 }, FishingOption.HARPOON, FishingOption.H_NET, FishingOption.BARB_HARPOON),
SPOT_MORTMYRE(new int[] {5748, 5749}, FishingOption.MORTMYRE_ROD),
SPOT_LUMDSAWMP(new int[] {2067, 2068}, FishingOption.LUMBDSWAMP_ROD),
SPOT_KBWANJI(new int[] {1174}, FishingOption.KBWANJI_NET),
SPOT_KARAMBWAN(new int[] {1177}, FishingOption.KARAMBWAN_VES),
BAIT_EELS(new int[] {800}, FishingOption.OILY_FISHING_ROD);
public static HashMap<Integer,FishingSpot> spotMap = new HashMap<>();
static{
FishingSpot[] spots = values();
for (FishingSpot spot : spots) {
int[] spotIds = spot.ids;
for (int spotId : spotIds) {
spotMap.putIfAbsent(spotId, spot);
}
}
}
public static FishingSpot forId(int npcId) {
return spotMap.get(npcId);
}
/**
* The NPC ids.
*/
private final int[] ids;
/**
* The fishing options.
*/
private FishingOption options[];
/**
* Constructs a new {@code FishingSpot} {@code Object}.
* @param ids The NPC ids.
*/
FishingSpot(int[] ids, FishingOption... options) {
this.ids = ids;
this.options = options;
}
public FishingOption getOptionByName(String name){
for(FishingOption o : this.options){
if(o.getName().equals(name)){return o;}
}
System.out.println("Unhandled fishing spot option, spot id: " + this.ids[0] + " desired fishing option: " + name);
return FishingOption.SMALL_NET; //safe, default return.
}
/**
* Gets the ids.
* @return The ids.
*/
public int[] getIds() {
return ids;
}
/**
* Gets the options.
* @return The options.
*/
public FishingOption[] getOptions() {
return options;
}
}