Guest User

Untitled

a guest
Mar 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. package bm_chins_2.tasks;
  2.  
  3. import com.prime.api.extension.game.hybrid.local.Interaction;
  4. import com.runemate.game.api.hybrid.Environment;
  5. import com.runemate.game.api.hybrid.entities.GameObject;
  6. import com.runemate.game.api.hybrid.local.Skill;
  7. import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
  8. import com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem;
  9. import com.runemate.game.api.hybrid.location.Coordinate;
  10. import com.runemate.game.api.hybrid.location.navigation.basic.PredefinedPath;
  11. import com.runemate.game.api.hybrid.region.GameObjects;
  12. import com.runemate.game.api.script.framework.task.Task;
  13.  
  14. import static bm_chins_2.Conditions.*;
  15. import static bm_chins_2.VH.ME;
  16.  
  17. public class Set extends Task {
  18.  
  19. private final Coordinate[] ChinTraps = getChinTraps();
  20. private Coordinate Next;
  21.  
  22. @Override
  23. public void execute() {
  24. assert ChinTraps != null;
  25. for (Coordinate x : ChinTraps){
  26. GameObject aTrap = GameObjects.newQuery().names("Box trap").results().nearest();
  27. if (aTrap != null){
  28. Environment.getLogger().debug("\texiste trap");
  29. if (aTrap.getPosition() != x){
  30. Next = x;
  31. break;
  32. }
  33. } else {
  34. Next = ME.getPosition();
  35. break;
  36. }
  37. }
  38.  
  39. if (Next != null){
  40. PredefinedPath p = PredefinedPath.create(Next);
  41. if (p.step()){
  42. if (ME != null){
  43. if (ME.getAnimationId() == -1){
  44. SpriteItem trap = Inventory.getItems("Box trap").random();
  45.  
  46. if (trap != null){
  47. if (Interaction.interact("Lay", trap)){
  48. Environment.getLogger().debug("\tlaying...");
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
  56.  
  57. @Override
  58. public boolean validate() {
  59. return !hasFailedTrap() && !hasShakingBox() && !hasGroundTrap();
  60. }
  61.  
  62. private Coordinate[] getChinTraps() {
  63. switch (getMaxTrapAmount()) {
  64. case 3:
  65. return new Coordinate[] {
  66. ME.getPosition(),
  67. new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() + 1),
  68. new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() - 1)
  69. };
  70. case 4:
  71. return new Coordinate[] {
  72. ME.getPosition(),
  73. new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() + 1),
  74. new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() - 1),
  75. new Coordinate(ME.getPosition().getX() - 2, ME.getPosition().getY())
  76. };
  77. case 5:
  78. return new Coordinate[] {
  79. ME.getPosition(),
  80. new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() - 1),
  81. new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() + 1),
  82. new Coordinate(ME.getPosition().getX() + 1, ME.getPosition().getY() + 1),
  83. new Coordinate(ME.getPosition().getX() + 1, ME.getPosition().getY() - 1)
  84. };
  85. }
  86.  
  87. return null;
  88. }
  89.  
  90. private int getMaxTrapAmount() {
  91. int lvl = Skill.HUNTER.getCurrentLevel();
  92. if (lvl >= 80) {
  93. return 5;
  94. } else if (lvl >= 60) {
  95. return 4;
  96. } else if (lvl >= 40) {
  97. return 3;
  98. } else if (lvl >= 20) {
  99. return 2;
  100. }
  101. return 1;
  102. }
  103. }
Add Comment
Please, Sign In to add comment