PDA

View Full Version : [508] Slayer-Attack Requirments



Angel
June 21st, 2010, 16:31
[508] Slayer
Modified Files: NPCAttack.java
Tested On: Palidino Source

|| Introduction ||
PART I

By using he Monster Attack Packet you can add Slayer or other monster requirements that can be expanded to include some range bug fixes and attack fixes (I'll explain at the bottom)

If you are missing the packet for any reason please post so that I can give you the code for the packet.

NOTE TO ALL PEOPLE WHO THINKS THIS LOOKS "GROSS" I HAVE TRIED EVERYTHING TO MAKE THIS LOOK BETTER BUT STRANGELY THIS IS THE ONLY THING THAT WORKS. IF YOU DONT LIKE IT GO MAKE IT BETTER FOR YOURSELF, JUST REMEMBER WHO GAVE YOU THE START.

|| Explanation ||



if(n.npcType == 6221) { //Spiritual Mage


(npcType) = int npcId = p.stream.readUnsignedWord();

Or when you click the attack option of a NPC the client sends a the NPC ID#.
The NPC# for every NPC is different.



if(p.skillLvl[18] >= 82) {
p.attackingNPC = true;


Checks if your Slayer Level is grater then or equal to the requirment to attack them.
Resets your AttackNPC int and stops you from attacking the npc.



} else {
p.frames.sendMessage(p, "You need 5 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}


Resets your AttackNPC int and stops you from attacking the NPC.

Now to clarify why this is different from the actual combat is that this is the Pre-Combat step to attacking. Not the actual combat where next tutorial I will explain how to set up slayer tasks on a system where on my server I have ALL slayer tasks + the gem.

Now Here's The Full Code :)
Insert Into NPCAttack.java



/**
/*Slayer Level Requirements Created By Angel
*/
if(n.npcType == 1648 || n.npcType == 1650 || n.npcType == 1652) { //Crawling Hand
if(p.skillLvl[18] >= 5) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 5 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1832) { //Cave bug
if(p.skillLvl[18] >= 7) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 7 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 7787) { //Cave Crawler
if(p.skillLvl[18] >= 10) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 10 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1612) { //Banshee
if(p.skillLvl[18] >= 15) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 15 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1831) { //Cave slime
if(p.skillLvl[18] >= 17) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 17 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1632) { //Rockslug
if(p.skillLvl[18] >= 20) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 20 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 2804 || n.npcType == 2803 || n.npcType == 2805 || n.npcType == 2806) { //Desert Lizard
if(p.skillLvl[18] >= 22){
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 22 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 4227) { //Cockatrice
if(p.skillLvl[18] >= 25) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 25 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1633 || n.npcType == 1634 || n.npcType == 1635 || n.npcType == 1636) { //Pyrefiend
if(p.skillLvl[18] >= 30) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 30 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 114) { //Mogre
if(p.skillLvl[18] >= 32) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 32 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 3153) { //Harpie Bug Swarm
if(p.skillLvl[18] >= 33) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 33 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 7823) { //Wall Beast
if(p.skillLvl[18] >= 35) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 35 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 3201 || n.npcType == 3202) { //Killerwatt
if(p.skillLvl[18] >= 37) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 37 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 5751) { //Molanisk
if(p.skillLvl[18] >= 39) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 39 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 7813) { //Basilisk
if(p.skillLvl[18] >= 40) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 40 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 5417 || n.npcType == 5418) { //Terror Dog
if(p.skillLvl[18] >= 40) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 40 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 2850) { //Fever Spider
if(p.skillLvl[18] >= 42) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 42 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1643 || n.npcType == 1644 || n.npcType == 1645 || n.npcType == 1646 || n.npcType == 1647) { //Infernal Mage
if(p.skillLvl[18] >= 45) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 45 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 3707) { //Brine Rat
if(p.skillLvl[18] >= 47) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 47 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 6218 || n.npcType == 6219) { //Bloodveld
if(p.skillLvl[18] >= 50) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 50 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1637 || n.npcType == 1638 || n.npcType == 1639 || n.npcType == 1641 || n.npcType == 1642
||n.npcType == 1640) { //Jelly
if(p.skillLvl[18] >= 52) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 52 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1622) { //Turoth
if(p.skillLvl[18] >= 55) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 55 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 3346) { //Zygomite
if(p.skillLvl[18] >= 57) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 57 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 4353) { //Cave Horror
if(p.skillLvl[18] >= 58) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 58 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 7801) { //Aberrant Spectre
if(p.skillLvl[18] >= 60) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 60 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 6220) { //Spiritual Ranger
if(p.skillLvl[18] >= 63) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 63 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1624) { //Dust Devil
if(p.skillLvl[18] >= 65) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 65 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 6219) { //Spiritual Warrior
if(p.skillLvl[18] >= 68) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 68 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 7811) { //Kurask
if(p.skillLvl[18] >= 70) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 70 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 3068) { //Skeletal Wyvern
if(p.skillLvl[18] >= 72) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 72 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 6389) { //Gargoyle
if(p.skillLvl[18] >= 75) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 75 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 1613) { //Nechryael
if(p.skillLvl[18] >= 80) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 80 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 6221) { //Spiritual Mage
if(p.skillLvl[18] >= 83) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 83 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}


if(n.npcType == 1615) { //Abyssal Demon
if(p.skillLvl[18] >= 85) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 85 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

if(n.npcType == 2783) { //Dark Beast
if(p.skillLvl[18] >= 90) {
p.attackingNPC = true;
} else {
p.frames.sendMessage(p, "You need 90 Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}


About Some Combat Fixes:

When you use range have you ever just ran up to the NPC? Well if you can create a Boolean that loops through a item array of lets say, Bows and sets it to true if the player equipment [3] = one of the ints in the array then you can tell the server when ever a attack is going to happen to stop the movement ;)

I found that this could be done with the Player on Player combat 2.

Credits: Me
YOU MUST ASK ME PERMISSION TO POST THIS ON ANOTHER FORUM/USE MY DIRECT SOURCE CODE

Aaron
June 21st, 2010, 16:34
I actually needed this exact same guide, Thank you very much for your help, All Credits to you 100%, I'll put that if I ever release my 508 That I am working on.

Angel
June 21st, 2010, 16:36
Why Thankyou :D I have 100% Slayer and Im thinking about releasing it. More comments and maybe I will :)

samuraiblood2
June 21st, 2010, 16:52
This is disgusting, why does everyone hardcode everything like this?

Angel
June 21st, 2010, 16:57
This is disgusting, why does everyone hardcode everything like this?

? Explain

If your refering to my conventions they are perfect. Thats how it's supposed to be done.

samuraiblood2
June 21st, 2010, 17:00
? Explain

If your refering to my conventions they are perfect. Thats how it's supposed to be done.

Only the registered members can see the link.

Angel
June 21st, 2010, 17:04
If you could have done better then please show me a link to something that I could be impressed by. There was no need to transfer it to a different file because it could just be classified under the packet. Instead of complaining about the tutorial and how you know what your doing give pointers on how it could be done better. Because telling me this is disgusting isn't helping anyone.

samuraiblood2
June 21st, 2010, 17:13
There was no need to transfer it to a different file because it could just be classified under the packet.
You not getting my point are you? Why write out hundreds of if statements when you can simply use an array or something. Stopping hardcoding isn't limited to just reading some file.

Rog3r
June 21st, 2010, 17:22
Redundant code is bad code. :(

Angel
June 21st, 2010, 17:34
*sigh* I wrote this about a year back when I had no idea about some of this information. The code must be called in this specific packet or else it won't work.

What I can do is create a switch statement, based off the level requirement and create a void within the packet (Or somewhere else IDC) because most of the infmormation is pretty simple.

Would that make you happy ;)

samuraiblood2
June 21st, 2010, 17:43
*sigh* I wrote this about a year back when I had no idea about some of this information. The code must be called in this specific packet or else it won't work.

What I can do is create a switch statement, based off the level requirement and create a void within the packet (Or somewhere else IDC) because most of the infmormation is pretty simple.

Would that make you happy ;)Not at all, making a huge switch statement wouldn't be much different from what you already have.

Angel
June 21st, 2010, 17:52
Ok your hard to please...what I did was this:



private void slayerreq(Player p, int lvl) {
if(p.skillLvl[18] >= lvl){
p.attackingNPC = true;
} else {
p.frames.sendMessage(p,"You need" +lvl+ "Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

added this then


switch (n.npcType) {
case xxxx:
(p, 25);
break;


If you dont like that then you can refract it.

samuraiblood2
June 21st, 2010, 18:06
Ok your hard to please...what I did was this:



private void slayerreq(Player p, int lvl) {
if(p.skillLvl[18] >= lvl){
p.attackingNPC = true;
} else {
p.frames.sendMessage(p,"You need" +lvl+ "Slayer to attack this monster.");
p.attackNPC = 0;
p.attackingNPC = false;
}
}

added this then


switch (n.npcType) {
case xxxx:
(p, 25);
break;


If you dont like that then you can refract it.



public class Slayer {

private static final int[] SLAYER_TASKS = { 1 };
private static final int[] SLAYER_TASK_LEVELS = { 1 };

public static void doSlayer(Player player, int npc) {
final int SLAYER_SKILL = 18;

if (isSlayerTask(npc)) {
if (player.skillLvl[SLAYER_SKILL] >= getSlayerTaskLevel()) {
player.attackNPC = true;
return;
}
player.frams.sendMessage(player, "You ned a Slayer level of " + getSlayerTaskLevel() + " to attack this monster.");
player.attackNPC = 0;
player.attackNPC = false;
}
}

private static boolean isSlayerTask(int npc) {
for (int i = 0; i < SLAYER_TASKS; i++) {
return npc == SLAYER_TASKS[i];
}
return false;
}

private static int getSlayerTaskLevel(int npc) {
for (int i = 0; i < SLAYER_TASKS; i++) {
if (SLAYER_TASKS[i] == npc) {
return SLAYER_TASK_LEVELS[i];
}
}
return 0;
}
}
Didn't compile/test the above but it should work fine. You would add new slayer tasks to the first array and the required levels to attack them in the second. You would then simply call the doSlayer(Player,int) method wherever.

Angel
June 21st, 2010, 18:10
I was Like O_O I am impressed. I will give you credits because you just completely blew my method out of the water :'( I'll get this up and running and test it.

Appology for getting angry, ;) Im gona blame the red ninja for this one.

samuraiblood2
June 21st, 2010, 18:13
I was Like O_O I am impressed. I will give you credits because you just completely blew my method out of the water :'( I'll get this up and running and test it.

Its not that impressive and is actually a very simple concept.


Appology for getting angry, ;) Im gona blame the red ninja for this on
That's fine, I acted like a bit of a dick myself.

The Soul
June 21st, 2010, 18:14
public class Slayer {

private static final int[] SLAYER_TASKS = { 1 };
private static final int[] SLAYER_TASK_LEVELS = { 1 };

public static void doSlayer(Player player, int npc) {
final int SLAYER_SKILL = 18;

if (isSlayerTask(npc)) {
if (player.skillLvl[SLAYER_SKILL] >= getSlayerTaskLevel()) {
player.attackNPC = true;
return;
}
player.frams.sendMessage(player, "You ned a Slayer level of " + getSlayerTaskLevel() + " to attack this monster.");
player.attackNPC = 0;
player.attackNPC = false;
}
}

private static boolean isSlayerTask(int npc) {
for (int i = 0; i < SLAYER_TASKS; i++) {
return npc == SLAYER_TASKS[i];
}
return false;
}

private static int getSlayerTaskLevel(int npc) {
for (int i = 0; i < SLAYER_TASKS; i++) {
if (SLAYER_TASKS[i] == npc) {
return SLAYER_TASK_LEVELS[i];
}
}
return 0;
}
}
Didn't compile/test the above but it should work fine. You would add new slayer tasks to the first array and the required levels to attack them in the second. You would then simply call the doSlayer(Player,int) method wherever.

There are a couple minor errors in there but overall it looks like it's alright.

samuraiblood2
June 21st, 2010, 18:15
There are a couple minor errors in there but overall it looks like it's alright.

Well I did it in this quick reply box, so I was expecting at least some errors.

Angel
June 21st, 2010, 18:16
From testing it, its to complicated and messy to edit it. Im going to change it to switches because looping through two arrays is both unnecessary and confusing.

Thanks For Trying Though :P

pray my but
February 19th, 2011, 01:10
ohh! finally, I've been trying on this for a couple days now. Cookies for you.

Dodge'
March 18th, 2011, 19:33
This is like, straight out of bulby sources D: