Jump to content

Open Source Slayer


QBots

Recommended Posts

 

 

Packages should be lower case.

Oh and are you serious? Don't go making a class for every task -.-

 

It's the easiest way to do something like this. If you are here to criticize then don't help. smile.png

Can't you do the same thing with an enum which holds all the monsters data

 

 

You could. I think having an interface/class setup will be easier for something open-source. This way it's easier to add new stuff for anyone. Doesn't matter at all for something that like this.

Link to comment
Share on other sites

 

 

Packages should be lower case.

Oh and are you serious? Don't go making a class for every task -.-

 

It's the easiest way to do something like this. If you are here to criticize then don't help. smile.png

Can't you do the same thing with an enum which holds all the monsters data

 

Yep, I just played a bit around and did this. It would be way easier to grab your task data this way

Link to comment
Share on other sites

Packages should be lower case.

Oh and are you serious? Don't go making a class for every task -.-

It's the easiest way to do something like this. If you are here to criticize then don't help. :)

my criticism could help, I said don't use a class for every task, which means you could think of something else, such as an enum. (Sorry for not saying to use an enum in the first place)

The enum should contain data such as equipment requirements, their combat level, and their attack style (based on the attack style you could fight them using their weakness, e.g. Range beats Mage)

Link to comment
Share on other sites

here's how I do it:
 

   public void onMessage(String s) throws InterruptedException {
      if (s.contains("You're assigned to kill")) {
         String[] half = s.split(";");
         String[] token = half[0].split(" ");
         String[] token2 = half[1].split(" ");
         String monster = fixMonster(token[4].replaceAll(";", ""));
         int num = Integer.parseInt(token2[2]);
         this.t = new Task(monster, num);
         this.gem_checked = false;
      }
      else if (s.contains("You've completed your task")) {
         this.t.setNum(0);
         this.client.getInventory().interactWithName("Teleport to house", "Break");
      }
      else if (s.contains("You need something new to hunt")) {
         
      }
      else if (s.contains("I'm already under attack")) {
         this.npc = null;
      }
      else if (s.contains("You have been poisoned")) {
         Item i = this.client.getInventory().getItemForNameThatContains("poison");
         this.client.getInventory().interactWithId(i.getId(), "Drink");
      }
   }
   
   public String fixMonster(String s) {
      String r = s;
      if (s.equalsIgnoreCase("rockslugs")) {
         r = "rockslug";
      }
      else if (s.equalsIgnoreCase("dogs")) {
         r = "guard dog";
      }
      else if (s.equalsIgnoreCase("kalphite")) {
         r = "kalphite";
         this.area = new Area(3460, 9475, 3473, 9493);
      }
      else if (s.equalsIgnoreCase("aberrant")) {
         r = "aberrant spectre";
         this.helm = 4168;
         this.chest = 5575;
         this.legs = 5576;
         this.pray_task = true;
         this.topray = Prayer.PROTECT_FROM_MAGIC;
      }
      else if (s.equalsIgnoreCase("banshees")) {
         this.helm = 4166;
         r = "banshee";
      }
      else if (s.equalsIgnoreCase("wolves")) {
         r = "wolf";
      }
      else if (s.equalsIgnoreCase("greater")) {
         r = "greater demon";
         this.area = new Area(2626, 9511, 2645, 9494);
      }
      else if (s.equalsIgnoreCase("fire")) {
         r = "fire giant";
         this.area = new Area(2584, 9885, 2575, 9899);
      }
      else if (s.endsWith("s")) {
         r = s.substring(0, s.length() - 1);
      }
      return r;
   }
Link to comment
Share on other sites

 

here's how I do it:

 

   public void onMessage(String s) throws InterruptedException {
      if (s.contains("You're assigned to kill")) {
         String[] half = s.split(";");
         String[] token = half[0].split(" ");
         String[] token2 = half[1].split(" ");
         String monster = fixMonster(token[4].replaceAll(";", ""));
         int num = Integer.parseInt(token2[2]);
         this.t = new Task(monster, num);
         this.gem_checked = false;
      }
      else if (s.contains("You've completed your task")) {
         this.t.setNum(0);
         this.client.getInventory().interactWithName("Teleport to house", "Break");
      }
      else if (s.contains("You need something new to hunt")) {
         
      }
      else if (s.contains("I'm already under attack")) {
         this.npc = null;
      }
      else if (s.contains("You have been poisoned")) {
         Item i = this.client.getInventory().getItemForNameThatContains("poison");
         this.client.getInventory().interactWithId(i.getId(), "Drink");
      }
   }
   
   public String fixMonster(String s) {
      String r = s;
      if (s.equalsIgnoreCase("rockslugs")) {
         r = "rockslug";
      }
      else if (s.equalsIgnoreCase("dogs")) {
         r = "guard dog";
      }
      else if (s.equalsIgnoreCase("kalphite")) {
         r = "kalphite";
         this.area = new Area(3460, 9475, 3473, 9493);
      }
      else if (s.equalsIgnoreCase("aberrant")) {
         r = "aberrant spectre";
         this.helm = 4168;
         this.chest = 5575;
         this.legs = 5576;
         this.pray_task = true;
         this.topray = Prayer.PROTECT_FROM_MAGIC;
      }
      else if (s.equalsIgnoreCase("banshees")) {
         this.helm = 4166;
         r = "banshee";
      }
      else if (s.equalsIgnoreCase("wolves")) {
         r = "wolf";
      }
      else if (s.equalsIgnoreCase("greater")) {
         r = "greater demon";
         this.area = new Area(2626, 9511, 2645, 9494);
      }
      else if (s.equalsIgnoreCase("fire")) {
         r = "fire giant";
         this.area = new Area(2584, 9885, 2575, 9899);
      }
      else if (s.endsWith("s")) {
         r = s.substring(0, s.length() - 1);
      }
      return r;
   }

 

That's kinda messy imo, but looks functional. I'll show you how I plan on doing it soon.

 

Link to comment
Share on other sites

That's kinda messy imo, but looks functional. I'll show you how I plan on doing it soon.

messy works till I need to fix it. plus I can put any info I need into it. Instead of writing a class for each task which has to be initialized anyway. this is just hard coded and ready to go. Most slayer stuff has to be anyway.

Link to comment
Share on other sites

 

That's kinda messy imo, but looks functional. I'll show you how I plan on doing it soon.

messy works till I need to fix it. plus I can put any info I need into it. Instead of writing a class for each task which has to be initialized anyway. this is just hard coded and ready to go. Most slayer stuff has to be anyway.

 

 

True.. I just think it's more readable with this setup but people dont seem to care about that on here.. Not to mention no one has to write any classes now because I made the taskgenerator which does all of the work.

Link to comment
Share on other sites

You still have to initialize each task with a ton of nulls.

TaskGenerator fire_giants = new TaskGenerator(234,54356,null,null,3243,4444,6766,null,null,null,null,null,new Area(1234,1234,2345,2345));

More readable, indeed

 

You have no idea how the initialiser works if you think that's the case. The taskgenerator is a script that you run. Lmao.

Link to comment
Share on other sites

You still have to initialize each task with a ton of nulls.

TaskGenerator fire_giants = new TaskGenerator(234,54356,null,null,3243,4444,6766,null,null,null,null,null,new Area(1234,1234,2345,2345));

More readable, indeed

 

You have no idea how the initialiser works if you think that's the case. The taskgenerator is a script that you run. Lmao.

Correct, since you haven't pushed it yet.

But anyhow, that initializer either has the same structure of mine or has a bunch of STask fire_giants = new STask(234,54356,null,null,3243,4444,6766,null,null,null,null,null,new Area(1234,1234,2345,2345));

I was not commenting on the type of code, I'm commenting on the structure of the class that contains your task. Why go through the trouble of initializing 20 task variables inside your STask class (and it will probably grow to larger than 20.. mine is at 12) when you could just leave the default and set what you need to. Most tasks require the same armor. It it necessary to pass the ID's for all your equipment pieces when you could just leave them default and change your helm for when you get an aberrant spectre task?

Sure it looks nice, but is it functional well written code? no

I'm not bashing your coding style, because I started doing it the same way. I just found this much much easier. It has very good applications, but this is not one of them

Edited by dreamliner
Link to comment
Share on other sites

Rather than define new classes for each available NPC, create a new enum and implement your interface onto it and make the enum's constructor parameters accept the required info per profile. It'd be a nice way to document each task.

 

Then again, the wide, vast variety of NPC and their combat preferences calls for a framework that's almost 100% adaptable, for instance; you have #getFinisher() method, but some tasks may require you to provoke the enemy NPC before combat can ensue.

 

Edited by liverare
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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