Created
March 12, 2021 16:21
Fishing F2P 0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Osplay.Fishing.Config"> | |
<grid id="27dc6" binding="root" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | |
<margin top="0" left="0" bottom="0" right="0"/> | |
<constraints> | |
<xy x="20" y="20" width="500" height="400"/> | |
</constraints> | |
<properties/> | |
<border type="none"/> | |
<children> | |
<component id="ba4b" class="javax.swing.JCheckBox" binding="drop"> | |
<constraints> | |
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<selected value="true"/> | |
<text value="Drop fish."/> | |
<toolTipText value="Check if you want to drop the fishes."/> | |
</properties> | |
</component> | |
<vspacer id="1b570"> | |
<constraints> | |
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> | |
</constraints> | |
</vspacer> | |
<component id="61dfa" class="javax.swing.JCheckBox" binding="bank"> | |
<constraints> | |
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Bank fish."/> | |
<toolTipText value="Check if you want to bank the fishes."/> | |
</properties> | |
</component> | |
<component id="ee6c2" class="javax.swing.JCheckBox" binding="getFishingItemFromCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<selected value="true"/> | |
<text value="Get Fishing Item from the ground."/> | |
</properties> | |
</component> | |
</children> | |
</grid> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Osplay.Fishing; | |
import javax.swing.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
public class Config extends JFrame{ | |
private JCheckBox drop; | |
private JCheckBox bank; | |
private JPanel root; | |
private JCheckBox getFishingItemFromCheckBox; | |
public Config(){ | |
add(root); | |
setTitle("AIO Fishing F2P"); | |
setVisible(true); | |
setSize(400,100); | |
drop.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
if(drop.isSelected()){ | |
Main.CONFIG_DROP = true; | |
bank.setSelected(false); | |
} else { | |
Main.CONFIG_DROP = false; | |
bank.setSelected(true); | |
} | |
} | |
}); | |
bank.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
if(bank.isSelected()){ | |
Main.CONFIG_DROP = false; | |
drop.setSelected(false); | |
} else { | |
Main.CONFIG_DROP = true; | |
drop.setSelected(true); | |
} | |
} | |
}); | |
getFishingItemFromCheckBox.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
if(getFishingItemFromCheckBox.isSelected()){ | |
Main.CONFIG_GET_GROUND = true; | |
} else { | |
Main.CONFIG_GET_GROUND = false; | |
} | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Osplay.Fishing; | |
import org.osbot.rs07.api.map.Area; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class Datos { | |
public Area LugarAPescar = null; | |
public Area LugarBanco = null; | |
public String FishingSpot = ""; | |
public List<String> ListaDeItems = new ArrayList<String>(); | |
public List<String> Pescados = new ArrayList<String>(); | |
public Lugares Lugar; | |
public Datos(Area lugarAPescar, Lugares lugar, Area lugarBanco, String fishingSpot, List<String> listaDeItems, List<String> pescados) { | |
this.LugarAPescar = lugarAPescar; | |
this.LugarBanco = lugarBanco; | |
this.FishingSpot = fishingSpot; | |
this.ListaDeItems = listaDeItems; | |
this.Pescados = pescados; | |
this.Lugar = lugar; | |
} | |
public enum Lugares { | |
LUMBRIDGE, | |
BARBARIAN_VILLAGE, | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Osplay.Fishing; | |
// Added cook fish if exist [X] | |
// Added fishing with leaves [X] | |
import org.osbot.rs07.api.Objects; | |
import org.osbot.rs07.api.map.Area; | |
import org.osbot.rs07.api.map.Position; | |
import org.osbot.rs07.api.map.constants.Banks; | |
import org.osbot.rs07.api.model.Entity; | |
import org.osbot.rs07.api.model.GroundItem; | |
import org.osbot.rs07.api.model.Item; | |
import org.osbot.rs07.api.model.RS2Object; | |
import org.osbot.rs07.api.ui.Skill; | |
import org.osbot.rs07.api.ui.Tab; | |
import org.osbot.rs07.script.Script; | |
import org.osbot.rs07.script.ScriptManifest; | |
import org.osbot.rs07.utility.ConditionalSleep; | |
import javax.swing.*; | |
import java.util.ArrayList; | |
import java.util.List; | |
@ScriptManifest(info = "AIO Fisher F2P", author = "OsPlay", version = 0.0, name = "Fishing F2P" ,logo = "") | |
public class Main extends Script { | |
public static boolean CONFIG_GET_GROUND = true; | |
public boolean PARAR = false; | |
public static boolean CONFIG_DROP = true; | |
public Datos datos = null; | |
Config c = new Config(); | |
@Override | |
public void onExit() throws InterruptedException { | |
c.setVisible(false); | |
PARAR = true; | |
} | |
@Override | |
public void pause() { | |
PARAR = true; | |
c.setVisible(false); | |
} | |
@Override | |
public void onStart() throws InterruptedException { | |
PARAR = false; | |
List<String> listadeitems = new ArrayList<>(); | |
List<String> pescados = new ArrayList<String>(); | |
pescados.add("Raw shrimps"); | |
pescados.add("Raw anchovies"); | |
listadeitems.add("Small fishing net"); | |
datos = new Datos(new Area(3243,3155,3237,3149), Datos.Lugares.LUMBRIDGE, Banks.LUMBRIDGE_UPPER, "Fishing spot", listadeitems, pescados); | |
SwingUtilities.invokeLater(new Runnable() { | |
@Override | |
public void run() { | |
c.setVisible(true); | |
} | |
}); | |
} | |
@Override | |
public void resume() { | |
c.setVisible(true); | |
PARAR = false; | |
} | |
@Override | |
public int onLoop() throws InterruptedException { | |
// For debugging security xD | |
sleep(500); | |
log("Player is not connected!"); | |
if(!getClient().isLoggedIn() && !myPlayer().isVisible()) return 1000; | |
log("Searching for skills..."); | |
if(!verificarSkills()) return 1000; | |
log("Checking inventory..."); | |
if(!verificarInventario()) depositarItemsEnElBanco(); | |
log("Searching for items..."); | |
if(!verificarItems()) return 1000; | |
log("Checking position..."); | |
if(!verificarPosicion()) caminar(datos.LugarAPescar); | |
log("Executing task..."); | |
if(!pescar()) return 1000; | |
return 1000; | |
} | |
private boolean pescar() throws InterruptedException { | |
while(true){ | |
if(PARAR) return false; | |
if(!verificarInventario()) return false; | |
if (verificarSiEstaPescando()) { | |
new ConditionalSleep(10000, 1000) { | |
@Override | |
public boolean condition() throws InterruptedException { | |
if(PARAR) return true; | |
if(verificarSiEstaPescando()) return false; | |
return false; | |
} | |
}.sleep(); | |
} else{ | |
Entity lugarAPescar = getNpcs().closest(datos.FishingSpot); | |
if(lugarAPescar == null) return false; | |
if(!lugarAPescar.interact()) return false; | |
getMouse().moveOutsideScreen(); | |
sleep(3000); | |
} | |
} | |
} | |
// | |
private boolean verificarSiEstaPescando() throws InterruptedException { | |
if(myPlayer().isMoving()) return false; | |
for(int i = 0; i < 5; i++){ | |
sleep(1000); | |
if(PARAR) return false; | |
if(myPlayer().isAnimating()){ | |
return true; | |
} | |
} | |
return false; | |
} | |
private boolean verificarPosicion() { | |
if(getPlayers().myPosition().distance(datos.LugarAPescar.getRandomPosition()) > 5) return false; | |
return true; | |
} | |
private void depositarItemsEnElBanco() throws InterruptedException { | |
log("Going to deposit or dropping..."); | |
if(CONFIG_DROP){ | |
dropear(); | |
return; | |
} | |
if(getPlayers().myPosition().distance(datos.LugarBanco.getRandomPosition()) > 5){ | |
caminar(datos.LugarBanco); | |
sleep(1000); | |
depositarItemsEnElBanco(); | |
return; | |
} | |
while(!getBank().isOpen()){ | |
getBank().open(); | |
new ConditionalSleep(5000, 1000) { | |
@Override | |
public boolean condition() throws InterruptedException { | |
if(getBank().isOpen()) return true; | |
if(PARAR) return true; | |
return false; | |
} | |
}.sleep(); | |
} | |
for(String name : datos.ListaDeItems){ | |
getBank().depositAllExcept(name); | |
} | |
getBank().close(); | |
if(getInventory().isFull()) return; | |
} | |
private boolean verificarInventario() { | |
if(getInventory().isFull()) return false; | |
return true; | |
} | |
private boolean verificarItems() throws InterruptedException { | |
abrirTab(Tab.INVENTORY); | |
boolean existe = false; | |
for (String nombre : | |
datos.ListaDeItems) { | |
if(PARAR) return false; | |
for(Item item : getInventory().getItems()){ | |
if(item == null) continue; | |
if(nombre.toLowerCase().equals(item.getName().toLowerCase())) existe = true; | |
} | |
if(!existe && CONFIG_GET_GROUND) { | |
irAPorElItem(); | |
} else if(existe){ | |
return true; | |
} | |
} | |
log("The item required for fishing is not in the world or you don't have it in the inventory!"); | |
return false; | |
} | |
private void irAPorElItem() throws InterruptedException { | |
log("Going to pick the item!"); | |
Area posicionItem; | |
switch(datos.Lugar){ | |
case LUMBRIDGE: | |
posicionItem = new Area(3243,3155,3237,3149); | |
getWalking().webWalk(posicionItem); | |
while (getInventory().getItem(datos.ListaDeItems.get(0)) == null) { | |
log("Trying to get the item!"); | |
if(PARAR) return; | |
RS2Object ob = getObjects().closestThatContains(datos.ListaDeItems.get(0)); | |
if(ob != null){ | |
log("exist!"); | |
ob.interact("Take"); | |
} else { | |
log("no exist!"); | |
} | |
new ConditionalSleep(5000, 1000) { | |
@Override | |
public boolean condition() throws InterruptedException { | |
if(PARAR) return true; | |
if(getObjects().closestThatContains(datos.ListaDeItems.get(0)) != null) return true; | |
return false; | |
} | |
}.sleep(); | |
sleep(1000); | |
} | |
break; | |
default: | |
log("No position for get this item."); | |
break; | |
} | |
} | |
private void abrirTab(Tab tab) { | |
if(getTabs().isOpen(tab)) return; | |
while (!getTabs().isOpen(tab)){ | |
if(PARAR) return; | |
getTabs().open(tab); | |
new ConditionalSleep(10000, 1000) { | |
@Override | |
public boolean condition() throws InterruptedException { | |
if(PARAR) return true; | |
if(getTabs().isOpen(tab)) return true; | |
return false; | |
} | |
}.sleep(); | |
} | |
} | |
boolean verificarSkills(){ | |
int skill = getSkills().getDynamic(Skill.FISHING); | |
log("Your skill is: " + skill); | |
List<String> listadeitems = new ArrayList<>(); | |
List<String> pescados = new ArrayList<String>(); | |
// TODO : AGREGAR NUEVOS NIVELES! | |
if(skill <= 100){ | |
pescados.add("Raw shrimps"); | |
pescados.add("Raw anchovies"); | |
listadeitems.add("small fishing net"); | |
datos = new Datos(new Area(3243,3155,3237,3149), Datos.Lugares.LUMBRIDGE, Banks.LUMBRIDGE_UPPER, "Fishing spot", listadeitems, pescados); | |
return true; | |
} | |
return false; | |
} | |
void caminar(Area area) throws InterruptedException { | |
getWalking().webWalk(area); | |
} | |
void dropear(){ | |
for (String pescados : | |
datos.Pescados) { | |
getInventory().dropAll(pescados); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment