Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.44 KB | None | 0 0
  1. package dragonkk.rs2rsps.model.player;
  2.  
  3. import java.io.Serializable;
  4.  
  5. import dragonkk.rs2rsps.model.Container;
  6. import dragonkk.rs2rsps.model.Item;
  7. import dragonkk.rs2rsps.rscache.ItemDefinitions;
  8.  
  9. public class Equipment implements Serializable{
  10.  
  11. private static final long serialVersionUID = -2934091862414178786L;
  12.  
  13. private transient Player player;
  14.  
  15. public static final byte SLOT_HAT = 0, SLOT_CAPE = 1, SLOT_AMULET = 2, SLOT_WEAPON = 3, SLOT_CHEST = 4, SLOT_SHIELD = 5, SLOT_LEGS = 7, SLOT_HANDS = 9, SLOT_FEET = 10, SLOT_RING = 12, SLOT_ARROWS = 13;
  16.  
  17. private Container<Item> equipment = new Container<Item>(15, false);
  18.  
  19. public Container<Item> getEquipment() {
  20. return equipment;
  21. }
  22.  
  23. public void setPlayer(Player player) {
  24. for(Item item : getEquipment().getItems())
  25. if(item != null)
  26. item.setDefinition(ItemDefinitions.forID(item.getId()));
  27. this.player = player;
  28. }
  29.  
  30. public boolean contains(int item) {
  31. return equipment.containsOne(new Item(item));
  32. }
  33. public void deleteItem(int item, int amount) {
  34. equipment.remove(new Item(item, amount));
  35. refresh();
  36. }
  37.  
  38. public Item get(int slot) {
  39. return equipment.get(slot);
  40. }
  41.  
  42. public void set(int slot, Item item) {
  43. equipment.set(slot, item);
  44. //if (slot == 3)
  45. //reset spec
  46. refresh();
  47. }
  48.  
  49. public void clear() {
  50. equipment.clear();
  51. refresh();
  52. }
  53.  
  54. public void refresh() {
  55. //if (player.isOnline())
  56. //player.getActionSender().SendSound(2248,100,0);
  57. player.getMask().setApperanceUpdate(true);
  58. player.getFrames().sendItems(94, equipment, false);
  59. player.getCombatDefinitions().refreshBonuses();
  60. player.getCombat().removeTarget();
  61. player.getCombatDefinitions().setSpecialOff();
  62. }
  63.  
  64. private static String[] CAPES = {"druidic cloak", "cape","Cape","Ava's accumulator"};
  65. private static String[] HATS = {"Air tiara", "tiara", "druidic wreath", "halo", "Royal", "crown", "sallet","helm","hood","coif","Coif","hat","partyhat","Hat","full helm (t)","full helm (g)","hat (t)","hat (g)","cav","boater","helmet","mask","Helm of neitiznot"};
  66. private static String[] BOOTS = {"boots","Boots", "shoes", "Shoes"};
  67. private static String[] GLOVES = {"gloves","gauntlets","Gloves","vambraces","vamb","bracers"};
  68. private static String[] SHIELDS = {"kiteshield","sq shield","Toktz-ket","books","book","kiteshield (t)","kiteshield (g)","kiteshield(h)","defender","shield","Divine spirit shield"};
  69. private static String[] AMULETS = {"amulet","necklace","Amulet of", "scarf"};
  70. private static String[] ARROWS = {"Hand cannon shot", "arrow","arrows","arrow(p)","arrow(+)","arrow(s)","bolt","Bolt rack","Opal bolts","Dragon bolts", "bolts (e)", "bolts"};
  71. private static String[] RINGS = {"ring","Ring"};
  72. private static String[] BODY = {"Royal shirt", "armour", "hauberk","platebody","chainbody","robetop","leathertop","platemail","top","brassard","Robe top","body","platebody (t)","platebody (g)","body(g)","body_(g)","chestplate","torso","shirt"};
  73. private static String[] LEGS = {"Royal leggings", "druidic robe", "cuisse", "pants","platelegs","plateskirt","skirt","bottoms","chaps","platelegs (t)","platelegs (g)","bottom","skirt","skirt (g)","skirt (t)","chaps (g)","chaps (t)","tassets","legs", "trousers", "robe bottom"};
  74. private static String[] WEAPONS = {"Royal sceptre", "Chaotic rapier", "Dragon dagger (p++)", "(p++)", "dagger", "dagger p++", "bow", "Hand cannon","inferno adze", "Dragon","Darklight","wand", "Statius's warhammer", "anchor","spear.", "Vesta's longsword.", "scimitar","longsword","sword","longbow","shortbow","dagger","mace","halberd","spear",
  75. "Abyssal whip","axe","flail","crossbow","Torags hammers","dagger(p)","dagger(+)","dagger(s)","spear(p)","spear(+)","Dharok's greataxe","Silverlight","dragon axe","dragon hatchet",
  76. "spear(s)","spear(kp)","maul","dart","dart(p)","javelin","javelin(p)","knife","knife(p)","Longbow","Shortbow",
  77. "Crossbow","Toktz-xil","Toktz-mej","Tzhaar-ket","staff","Staff","godsword","c'bow","Crystal bow","Dark bow","claws", "warhammer", "adze", "hand", "hatchet"};
  78. private static String[] FULL_BODY = {"Investigator's coat", "armour", "hauberk", "top","shirt","platebody","Ahrims robetop","Karils leathertop","brassard","Robe top","robetop","platebody (t)","platebody (g)","chestplate","torso", "Morrigan's", "leather body", "chainbody", "Zuriel's", "robe top"};
  79. private static String[] FULL_HAT = {"sallet", "med helm","coif","Dharoks helm","hood","Initiate helm","Coif","Helm of neitiznot"};
  80. private static String[] FULL_MASK = {"Christmas ghost hood", "Dragon full helm (or)", "sallet","full helm","mask","Veracs helm","Guthans helm","Torags helm","Karils coif","full helm (t)","full helm (g)","mask"};
  81.  
  82. public static int getItemType(int wearId) {
  83. try {
  84. String weapon = ItemDefinitions.forID(wearId).name;
  85. for(int i = 0; i < CAPES.length; i++) {
  86. if(weapon.contains(CAPES[i]))
  87. return 1;
  88. }
  89. for(int i = 0; i < HATS.length; i++) {
  90. if(weapon.contains(HATS[i]))
  91. return 0;
  92. }
  93. for(int i = 0; i < BOOTS.length; i++) {
  94. if(weapon.endsWith(BOOTS[i]) || weapon.startsWith(BOOTS[i]))
  95. return 10;
  96. }
  97. for(int i = 0; i < GLOVES.length; i++) {
  98. if(weapon.endsWith(GLOVES[i]) || weapon.startsWith(GLOVES[i]))
  99. return 9;
  100. }
  101. for(int i = 0; i < SHIELDS.length; i++) {
  102. if(weapon.contains(SHIELDS[i]))
  103. return 5;
  104. }
  105. for(int i = 0; i < AMULETS.length; i++) {
  106. if(weapon.endsWith(AMULETS[i]) || weapon.startsWith(AMULETS[i]))
  107. return 2;
  108. }
  109. for(int i = 0; i < ARROWS.length; i++) {
  110. if(weapon.endsWith(ARROWS[i]) || weapon.startsWith(ARROWS[i]))
  111. return 13;
  112. }
  113. for(int i = 0; i < RINGS.length; i++) {
  114. if(weapon.endsWith(RINGS[i]) || weapon.startsWith(RINGS[i]))
  115. return 12;
  116. }
  117. for(int i = 0; i < BODY.length; i++) {
  118. if(weapon.contains(BODY[i]))
  119. return 4;
  120. }
  121. for(int i = 0; i < LEGS.length; i++) {
  122. if(weapon.contains(LEGS[i]))
  123. return 7;
  124. }
  125. for(int i = 0; i < WEAPONS.length; i++) {
  126. if(weapon.endsWith(WEAPONS[i]) || weapon.startsWith(WEAPONS[i]))
  127. return 3;
  128. }
  129. return -1;
  130. } catch(Exception e) {
  131. return -1;
  132. }
  133. }
  134.  
  135. public static boolean isFullBody(ItemDefinitions def) {
  136. String weapon = def.name;
  137. for (int i = 0; i < FULL_BODY.length; i++) {
  138. if (weapon.contains(FULL_BODY[i])) {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144.  
  145.  
  146. public static boolean isFullHat(ItemDefinitions def) {
  147. String weapon = def.name;
  148. for (int i = 0; i < FULL_HAT.length; i++) {
  149. if (weapon.endsWith(FULL_HAT[i])) {
  150. return true;
  151. }
  152. }
  153. return false;
  154. }
  155.  
  156. public static boolean isFullMask(ItemDefinitions def) {
  157. String weapon = def.name;
  158. for (int i = 0; i < FULL_MASK.length; i++) {
  159. if (weapon.endsWith(FULL_MASK[i])) {
  160. return true;
  161. }
  162. }
  163. return false;
  164. }
  165.  
  166. public static boolean isTwoHanded(ItemDefinitions def) {
  167. String wepEquiped = def.name;
  168. int itemId = def.getId();
  169. if (itemId == 4212)
  170. return true;
  171. else if (itemId == 4214)
  172. return true;
  173. else if (wepEquiped.endsWith("claws"))
  174. return true;
  175. else if (wepEquiped.endsWith("anchor"))
  176. return true;
  177. else if (wepEquiped.endsWith("2h sword"))
  178. return true;
  179. else if (wepEquiped.endsWith("longbow"))
  180. return true;
  181. else if (wepEquiped.equals("Seercull"))
  182. return true;
  183. else if (wepEquiped.endsWith("shortbow"))
  184. return true;
  185. else if (wepEquiped.endsWith("Longbow"))
  186. return true;
  187. else if (wepEquiped.endsWith("Shortbow"))
  188. return true;
  189. else if (wepEquiped.endsWith("bow full"))
  190. return true;
  191. else if (wepEquiped.equals("Dark bow"))
  192. return true;
  193. else if (wepEquiped.endsWith("halberd"))
  194. return true;
  195. else if (wepEquiped.equals("Granite maul"))
  196. return true;
  197. else if (wepEquiped.equals("Chaotic maul"))
  198. return true;
  199. else if (wepEquiped.equals("Karils crossbow"))
  200. return true;
  201. else if (wepEquiped.equals("Torags hammers"))
  202. return true;
  203. else if (wepEquiped.equals("Veracs flail"))
  204. return true;
  205. else if (wepEquiped.equals("Dharok's greataxe"))
  206. return true;
  207. else if (wepEquiped.equals("Guthans warspear"))
  208. return true;
  209. else if (wepEquiped.equals("Dragon axe"))
  210. return true;
  211. else if (wepEquiped.equals("Tzhaar-ket-om"))
  212. return true;
  213. else if (wepEquiped.endsWith("godsword"))
  214. return true;
  215. else if (wepEquiped.equals("Saradomin sword"))
  216. return true;
  217. else
  218. return false;
  219. }
  220. public int getRenderAnim() { //TODO cache sided
  221. if(get(3) == null)
  222. return 1426;
  223. int renderEmote = get(3).getDefinition().renderEmote;
  224. if(renderEmote != 0)
  225. return renderEmote;
  226. return 1426;
  227. }
  228. public void setAttStyle() {
  229. int MaxSize = 3;
  230. if(player.getEquipment().get(3) == null) {
  231. MaxSize = 2;
  232. }else if(player.getEquipment().get(3) != null) {
  233. } if (player.getCombatDefinitions().getAttackStyle() > MaxSize)
  234. player.getCombatDefinitions().setAttackStyle((byte) MaxSize);
  235. player.getFrames().sendConfig(43, player.getAttackStyle());
  236. }
  237. public String getAttStyle(ItemDefinitions def) {
  238. String style = null;
  239. String wepEquiped = def.name;
  240. if(player.getEquipment().get(3) == null) {
  241. switch(player.getAttackStyle()) {
  242. case 0:
  243. style = "Attack";
  244. break;
  245. case 1:
  246. style = "Strength";
  247. break;
  248. case 2:
  249. style = "Defence";
  250. break;
  251. }
  252. } else if(player.getEquipment().get(3) != null) {
  253. if (wepEquiped.endsWith("bow")) {
  254. switch(player.getCombatDefinitions().getAttackStyle()) {
  255. case 0:
  256. style = "Ranged";
  257. break;
  258. case 1:
  259. style = "Ranged";
  260. break;
  261. case 2:
  262. style = "RangedDefence";
  263. break;
  264. }
  265. }else{
  266. switch(player.getCombatDefinitions().getAttackStyle()) {
  267. case 0:
  268. style = "Attack";
  269. if (wepEquiped.contains("halberd"))
  270. style = "Shared";
  271. break;
  272. case 1:
  273. style = "Strength";
  274. if (wepEquiped.contains("whip"))
  275. style = "Shared";
  276. break;
  277. case 2:
  278. style = "Shared";
  279. if (wepEquiped.contains("whip") || wepEquiped.contains("Staff") || wepEquiped.contains("staff") || wepEquiped.contains("halberd"))
  280. style = "Defence";
  281. else if (wepEquiped.contains("godsword") || wepEquiped.contains("2h sword") || wepEquiped.contains("greataxe"))
  282. style = "Strength";
  283. break;
  284. case 3:
  285. style = "Defence";
  286. break;
  287. }
  288. }
  289. }
  290. return style;
  291. }
  292. public void setWeapon() {
  293. try {
  294. setAttStyle();
  295. if(player.getEquipment().get(3) == null) {
  296. player.getFrames().sendTab(85, 92);
  297. player.getFrames().sendString("Unarmed", 92, 0);
  298. return;
  299. }
  300. } catch(Exception e) {
  301. }
  302. }
  303.  
  304. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement