Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bm_chins_2.tasks;
- import com.prime.api.extension.game.hybrid.local.Interaction;
- import com.runemate.game.api.hybrid.Environment;
- import com.runemate.game.api.hybrid.entities.GameObject;
- import com.runemate.game.api.hybrid.local.Skill;
- import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
- import com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem;
- import com.runemate.game.api.hybrid.location.Coordinate;
- import com.runemate.game.api.hybrid.location.navigation.basic.PredefinedPath;
- import com.runemate.game.api.hybrid.region.GameObjects;
- import com.runemate.game.api.script.framework.task.Task;
- import static bm_chins_2.Conditions.*;
- import static bm_chins_2.VH.ME;
- public class Set extends Task {
- private final Coordinate[] ChinTraps = getChinTraps();
- private Coordinate Next;
- @Override
- public void execute() {
- assert ChinTraps != null;
- for (Coordinate x : ChinTraps){
- GameObject aTrap = GameObjects.newQuery().names("Box trap").results().nearest();
- if (aTrap != null){
- Environment.getLogger().debug("\texiste trap");
- if (aTrap.getPosition() != x){
- Next = x;
- break;
- }
- } else {
- Next = ME.getPosition();
- break;
- }
- }
- if (Next != null){
- PredefinedPath p = PredefinedPath.create(Next);
- if (p.step()){
- if (ME != null){
- if (ME.getAnimationId() == -1){
- SpriteItem trap = Inventory.getItems("Box trap").random();
- if (trap != null){
- if (Interaction.interact("Lay", trap)){
- Environment.getLogger().debug("\tlaying...");
- }
- }
- }
- }
- }
- }
- }
- @Override
- public boolean validate() {
- return !hasFailedTrap() && !hasShakingBox() && !hasGroundTrap();
- }
- private Coordinate[] getChinTraps() {
- switch (getMaxTrapAmount()) {
- case 3:
- return new Coordinate[] {
- ME.getPosition(),
- new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() + 1),
- new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() - 1)
- };
- case 4:
- return new Coordinate[] {
- ME.getPosition(),
- new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() + 1),
- new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() - 1),
- new Coordinate(ME.getPosition().getX() - 2, ME.getPosition().getY())
- };
- case 5:
- return new Coordinate[] {
- ME.getPosition(),
- new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() - 1),
- new Coordinate(ME.getPosition().getX() - 1, ME.getPosition().getY() + 1),
- new Coordinate(ME.getPosition().getX() + 1, ME.getPosition().getY() + 1),
- new Coordinate(ME.getPosition().getX() + 1, ME.getPosition().getY() - 1)
- };
- }
- return null;
- }
- private int getMaxTrapAmount() {
- int lvl = Skill.HUNTER.getCurrentLevel();
- if (lvl >= 80) {
- return 5;
- } else if (lvl >= 60) {
- return 4;
- } else if (lvl >= 40) {
- return 3;
- } else if (lvl >= 20) {
- return 2;
- }
- return 1;
- }
- }
Add Comment
Please, Sign In to add comment