Jump to content

PHillGiants Hill Giant Killer || Free || Open source


thepecher

Recommended Posts

So yeah basically i was bored and decided to come back to osbot after like 2 years. Ill probably be making a couple of scripts again at a later day but to get used to the API i made a couple of scripts. 

So i present to you PHillGiants, the simplest Hill Giant killer possible.

Features:

-Kills Hill Giants

-Banks for food

How to use:

- Have desired food in bank as well as a brass key

- Start script and fill in GUI

- Click on the start button

REMARKS:

-This script was created very quickly and barely tested, i will probably not support it any further but it should work fine now.

-Only tested on F2P where it struggled to find Hill Giants consistently because it was so populated. Will probably work a lot better on P2P or on rather empty worlds.

DOWNLOAD: http://www.filedropper.com/phillgiants

SOURCE:

Spoiler

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;
import java.util.Random;
 
@ScriptManifest(author = "Thepecher", info = "Kills HillGiants", name = "PHillGiants", version = 0, logo = "")
public class Main extends Script {
	public boolean looper=true;
	Random randomGenerator;
	Area giants = new Area(3095,9820,3126,9851);//z==0
	Area giantsCenter = new Area(3114,9838,3117,9841);//z==0
	int exp;
	String food="Salmon";
	long time;
	String status;
	public boolean started;
	GUI gui;
    @Override
    public void onStart() {
        log("Let's get started!");
        exp=skills.getExperience(Skill.ATTACK) + skills.getExperience(Skill.STRENGTH) + skills.getExperience(Skill.DEFENCE);
        randomGenerator = new Random();
        time=System.currentTimeMillis();
        gui = new GUI(this);
        started=false;
        gui.setVisible(true);
        
        
    }
 
    @Override
    public int onLoop() throws InterruptedException {
    	if(!started){
    		return 200;
    	}
    	food=gui.textField.getText();
    	gui.setVisible(false);
    	
    	status=getState();
    	switch (status){
    	case "FIGHTING":
    		NPC hillgiant=null;
    		if(!myPlayer().isAnimating() && !myPlayer().isUnderAttack() && !myPlayer().isMoving()){
    			for(NPC npc : getNpcs().getAll()) {
    				log("Testing "+npc.getName());
    				log("/"+npc.getName()+"/");
    				if(!npc.isUnderAttack() && npc.getName().equals("Hill Giant")){
    					log("Found one");
    					hillgiant=npc;
    					break;
    				}
    			}

    			if(hillgiant !=null){
    				hillgiant.interact("Attack");
    				sleep(random(1500,2000));
    			}
    		}
    		if(myPlayer().getHealthPercent()<50){
    			inventory.interact("Eat", food);
    		}
    		break;
    	case "BANKING":
    		if(!getBank().isOpen()){
    			getBank().open();
    		}else if(!getInventory().contains(food) && !getInventory().contains("Brass key")){
    			getBank().depositAll();
    			getBank().withdraw(food,27);
    			getBank().withdraw("Brass key", 1);
    		}
    		break;
    	case "GOING TO BANK":
    		getWalking().webWalk(Banks.VARROCK_WEST);
    		break;
    	case "GOING TO GIANTS":
    		getWalking().webWalk(giantsCenter);
    		break;
    	}
    	
        return random(2400, 3000);
    }
 
    @Override
    public void onExit() {
        log("Mad gains?");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
    	g.drawString("Combat EXP gained: " + (skills.getExperience(Skill.ATTACK) + skills.getExperience(Skill.STRENGTH) + skills.getExperience(Skill.DEFENCE)-exp), 20, 300);
    	g.drawString("Time running: "+ formatTime(System.currentTimeMillis()-time), 20, 280);
    	g.drawString("Status :"+status, 20, 260);
    }
    
    public String getState(){
    	if(giants.contains(myPosition()) && myPlayer().getHealthPercent()>30){
    		return "FIGHTING";
    	}else if(Banks.VARROCK_WEST.contains(myPosition()) && !inventory.contains(food)){
    		return "BANKING";
    	}else if(giants.contains(myPosition()) && !inventory.contains(food) && myPlayer().getHealthPercent()<30){
    		return "GOING TO BANK";
    	}else{return "GOING TO GIANTS";}
    	
    }
    public final String formatTime(final long ms){
        long s = ms / 1000, m = s / 60, h = m / 60;
        s %= 60; m %= 60; h %= 24;
        return String.format("%02d:%02d:%02d", h, m, s);
    }
}

GUI class (same package):




import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextField;
import javax.swing.JButton;

public class GUI extends JFrame {

	private JPanel contentPane;
	public JTextField textField;
	JButton btnStartScript;


	/**
	 * Create the frame.
	 */
	public GUI(Main main) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 448, 222);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblPhillgiants = new JLabel("PHillGiants");
		lblPhillgiants.setFont(new Font("Tahoma", Font.BOLD, 17));
		lblPhillgiants.setBounds(180, 11, 108, 34);
		contentPane.add(lblPhillgiants);
		
		JLabel lblPleaseEnterThe = new JLabel("Please enter the desired food: ");
		lblPleaseEnterThe.setBounds(10, 68, 159, 22);
		contentPane.add(lblPleaseEnterThe);
		
		textField = new JTextField();
		textField.setBounds(180, 69, 159, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		btnStartScript = new JButton("Start Script");
		btnStartScript.setBounds(180, 133, 89, 23);
		btnStartScript.addActionListener(new ActionListener() { 
			  public void actionPerformed(ActionEvent e) {
				  main.log("Pressed start");
				  main.started=true;
			  } 
			} );
		contentPane.add(btnStartScript);
	}
}

 

 

 

PS: ANYONE HAVE SCRIPT IDEAS?

Edited by thepecher
  • Like 2
Link to comment
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...