RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Agility.java
1package com.osroyale.content.skill.impl.agility;
2
3import com.google.gson.Gson;
4import com.google.gson.GsonBuilder;
5import com.google.gson.JsonIOException;
6import com.google.gson.JsonSyntaxException;
7import com.osroyale.Config;
8import com.osroyale.content.skill.impl.agility.obstacle.Obstacle;
9import com.osroyale.game.world.entity.mob.player.Player;
10import com.osroyale.game.world.entity.skill.Skill;
11import com.osroyale.game.world.items.Item;
12import com.osroyale.game.world.position.Position;
13
14import java.io.*;
15import java.util.HashMap;
16import java.util.function.Consumer;
17
52
53public class Agility {
54 public static final int GNOME_FLAGS = 0b0111_1111;
55 public static final int BARBARIAN_FLAGS = 0b0111_1111;
56 public static final int WILDERNESS_FLAGS = 0b0001_1111;
57 public static final int SEERS_FLAGS = 0b0011_1111;
58 public static final int ARDOUGNE_FLAGS = 0b0111_1111;
59 public static final HashMap<Position, Obstacle> obstacles = new HashMap<>();
60
61 public static void declare() {
62 try {
63 Obstacle[] loaded = new Gson().fromJson(new BufferedReader(new FileReader("./data/content/skills/agility.json")), Obstacle[].class);
64 for (Obstacle obstacle : loaded) {
65 if (obstacle.getObjectPosition() == null) {
66 obstacle.setObjectPosition(obstacle.getStart());
67 }
68 if (obstacle.getType() == null) {
69 System.out.println(obstacle + " No object type found. FIX MUST FIX");
70 }
71 obstacles.put(obstacle.getObjectPosition(), obstacle);
72 }
73 } catch (JsonSyntaxException | JsonIOException | FileNotFoundException e) {
74 e.printStackTrace();
75 }
76 }
77
78 private final static double TICKET_EXPERIENCE = 50 * Config.AGILITY_MODIFICATION;
79
80 public static boolean clickButton(Player player, int button) {
81 int amount = -1;
82 Consumer<Player> onClick = null;
83
84 switch (button) {
85 case 8387:
86 amount = 1;
87 onClick = p -> p.skills.addExperience(Skill.AGILITY, TICKET_EXPERIENCE * 1);
88 break;
89 case 8389:
90 amount = 10;
91 onClick = p -> p.skills.addExperience(Skill.AGILITY, TICKET_EXPERIENCE * 10);
92 break;
93 case 8390:
94 amount = 25;
95 onClick = p -> p.skills.addExperience(Skill.AGILITY, TICKET_EXPERIENCE * 25);
96 break;
97 case 8391:
98 amount = 100;
99 onClick = p -> p.skills.addExperience(Skill.AGILITY, TICKET_EXPERIENCE * 100);
100 break;
101 case 8392:
102 amount = 1_000;
103 onClick = p -> p.skills.addExperience(Skill.AGILITY, TICKET_EXPERIENCE * 1000);
104 break;
105 case 8382:
106 amount = 3;
107 onClick = p -> p.inventory.addOrDrop(new Item(3049, 1));
108 break;
109 case 8383:
110 amount = 10;
111 onClick = p -> p.inventory.addOrDrop(new Item(3051, 1));
112 break;
113 case 8381:
114 amount = 800;
115 onClick = p -> p.inventory.addOrDrop(new Item(2997, 1));
116 break;
117 }
118 if (amount > -1) {
119 if (player.inventory.contains(2996, amount)) {
120 player.inventory.remove(2996, amount);
121 onClick.accept(player);
122 player.interfaceManager.close();
123 return true;
124 } else {
125 player.message("You do not have enough agility tickets to purchase that.");
126 return true;
127 }
128 }
129 return false;
130 }
131
132 public static void main(String[] args) {
133 // Write the obstacles so we don't have to deal with ugly as fuck wall
134 // of code.
135// obstacles.put(new Location(2551, 3554), new Obstacle.ObstacleBuilder(ObstacleType.ROPE_SWING, new ObeliskData(2551, 3554), new ObeliskData(2551, 3549))
136// .setExperience(22f)
137// .setLevel(35)
138// .setOrdinal(0)
139// .setNext(new Obstacle.ObstacleBuilder(ObstacleType.ROPE_SWING, new Location(2551, 3554), new ObeliskData(2551, 3549)).build())
140// .build());
141
142 try (FileWriter writer = new FileWriter(new File("./data/def/skills/agility1.json"))) {
143 Gson builder = new GsonBuilder().setPrettyPrinting().create();
144
145 writer.write(builder.toJson(obstacles.values()).replaceAll("\\{\n \"x\"", "\\{ \"x\"").replaceAll(",\n \"y\"", ", \"y\"").replaceAll(",\n \"z\"", ", \"z\"").replaceAll("\n \\},", " \\},"));
146 } catch (Exception e) {
147 }
148 }
149
150}
static final double AGILITY_MODIFICATION
Definition Config.java:289