Add attack

This commit is contained in:
RedSparr0w
2019-10-20 22:31:04 +13:00
parent 5f5346497f
commit 8b8519b6b7
2 changed files with 46 additions and 1 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="3ab8e8a0-ccfd-4b0b-9547-98173085dc38" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/src/main/java/ParaScript/ui/UI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ParaScript/ui/UI.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@@ -0,0 +1,45 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Npcs;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.Npc;
import org.rev317.min.api.wrappers.SceneObject;
public class Killer implements Strategy {
private Npc victim;
@Override
public boolean activate() {
victim = victim(); // set the local Variable
if (Variables.running
&& victim != null
&& !Players.getMyPlayer().isInCombat()
&& Players.getMyPlayer().getAnimation() == -1
&& !Inventory.isFull()) {
return true;
}
return false;
}
@Override
public void execute() {
victim.interact(Npcs.Option.ATTACK);
Time.sleep(1000);
//Wait for the Player to finish pickpocketing
Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 500);
}
private Npc victim(){
for(Npc victim : Npcs.getNearest(41)){
if(victim != null){
return victim;
}
}
return null;
}
}