Thread: [PI] Attack cycling for NPCs (Inspired by RS3's KK)

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 [PI] Attack cycling for NPCs (Inspired by RS3's KK) 
    Registered Member
    Join Date
    Mar 2016
    Posts
    362
    Thanks given
    102
    Thanks received
    24
    Rep Power
    60
    Here is a very simple system for handling an irregular attack cycle, giving a boss potential mechanics, for this example, Here is the rotation.
    Reason you should add this: Bossing on RSPS's can be very plain, and this can spice it up a bit
    This is all in NPCHandler.java
    At the top declare
    Code:
    	public static short attackRotation = 0;
    This will be used to hold the attackRotation and let the server know which attack the cycle is on.
    If you want it to be for a boss that has one instance, use this. If you want it to have more then one, In the Player class declare
    Code:
    	public short attackRotation = 0;
    instead.
    Now go to NPCHandler and go to the handlespecialeffects() method
    In this example
    Code:
    	if (npcs[i].npcType == Your npc ID) {	
    			attackRotation++;
    			switch (attackRotation) {
    			case 8: 
    			attackRotation++;
    			break;
    			case 7:
    			attackRotation++;
    			break;
    			case 6:
    			attackRotation++;
    			break;
    			case 5:
    			attackRotation++;
    			break;
    			case 4:
    			attackRotation++;
    			break
    			case 3:
    			if(Misc.random(5) == 4){
    			attackRotation = 5;
    			}
    			attackRotation++;
    			break;
    			case 2:
    			attackRotation++;
    			break;
    			case 1:
    			attackRotation++;
    			break;
    			case 0:
    			attackRotation++;
    			break;
    			case 9:
    			attackRotation = 0;
    			break;
    		}
    }
    The reason the numbers 0-8 are written backwards is if they were not, it occurred in game where the entire cycle would rotate every time the NPC using the rotation attacked, so that is why it is in an abnormal order.
    You will have to add attacks for each part, as I won't be doing that for you.
    Reply With Quote  
     

  2. #2  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    A small part of me dies every time I see npcs[int].
    Let's not even get down to all those missing getters & setters.
    Attached image
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Registered Member
    Join Date
    Mar 2016
    Posts
    362
    Thanks given
    102
    Thanks received
    24
    Rep Power
    60
    Quote Originally Posted by Kris View Post
    A small part of me dies every time I see [I]npcs.
    Let's not even get down to all those missing getters & setters.
    i was really tired when I wrote this, but I believe that all I was missing in here (it's not actually missing in the code, just forgot to cp) is another bracket at the end
    this works fine otherwise, what is the issue with forcechats? Nex is quite a 'vocal' npc as I would call it and says a lot. If you mean to write it differently, if you use a different thing to [i] it can cause strange glitches
    The methods to do with corruption are to do with attacks I made for nex, and this isn't me giving a nex code, it's more the basic idea of how it works, so people can generate their own attacks within each case.
    Reply With Quote  
     

  5. #4  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Quote Originally Posted by ventusX View Post
    i was really tired when I wrote this, but I believe that all I was missing in here (it's not actually missing in the code, just forgot to cp) is another bracket at the end
    this works fine otherwise, what is the issue with forcechats? Nex is quite a 'vocal' npc as I would call it and says a lot. If you mean to write it differently, if you use a different thing to [i] it can cause strange glitches
    The methods to do with corruption are to do with attacks I made for nex, and this isn't me giving a nex code, it's more the basic idea of how it works, so people can generate their own attacks within each case.
    I'm not speaking of the actual functionality here, I'm just talking about the code. Ignore my initial post as formatting kinda ruined it and I can see why you didn't fully understand it.
    What I mean is the direct accessing of variables - you should always be using getters and setters. Not to mention these variable names are just terrible. And of course that huge loop of npcs.. It's just depressing. Completely defeating the purpose of java - OOP. Applying none of it in here basically.
    Attached image
    Reply With Quote  
     

  6. #5  
    Registered Member
    Join Date
    Mar 2016
    Posts
    362
    Thanks given
    102
    Thanks received
    24
    Rep Power
    60
    Quote Originally Posted by Kris View Post
    I'm not speaking of the actual functionality here, I'm just talking about the code. Ignore my initial post as formatting kinda ruined it and I can see why you didn't fully understand it.
    What I mean is the direct accessing of variables - you should always be using getters and setters. Not to mention these variable names are just terrible. And of course that huge loop of npcs.. It's just depressing. Completely defeating the purpose of java - OOP. Applying none of it in here basically.
    i'm gonna rewrite this in a minute
    Reply With Quote  
     

  7. #6  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Quote Originally Posted by ventusX View Post
    i'm gonna rewrite this in a minute
    Sir, I don't know what the hell you've done with it now, but whatever this is:
    Code:
    	if (npcs[i].npcType == Your npc ID) {	
    			attackRotation++;
    			switch (attackRotation) {
    			case 8: 
    			attackRotation++;
    			break;
    			case 7:
    			attackRotation++;
    			break;
    			case 6:
    			attackRotation++;
    			break;
    			case 5:
    			attackRotation++;
    			break;
    			case 4:
    			attackRotation++;
    			break
    			case 3:
    			if(Misc.random(5) == 4){
    			attackRotation = 5;
    			}
    			attackRotation++;
    			break;
    			case 2:
    			attackRotation++;
    			break;
    			case 1:
    			attackRotation++;
    			break;
    			case 0:
    			attackRotation++;
    			break;
    			case 9:
    			attackRotation = 0;
    			break;
    		}
    }
    is wrong.
    Attached image
    Reply With Quote  
     

  8. #7  
    Registered Member
    Join Date
    Mar 2016
    Posts
    362
    Thanks given
    102
    Thanks received
    24
    Rep Power
    60
    Quote Originally Posted by Kris View Post
    Sir, I don't know what the hell you've done with it now, but whatever this is:
    Code:
    	if (npcs[i].npcType == Your npc ID) {	
    			attackRotation++;
    			switch (attackRotation) {
    			case 8: 
    			attackRotation++;
    			break;
    			case 7:
    			attackRotation++;
    			break;
    			case 6:
    			attackRotation++;
    			break;
    			case 5:
    			attackRotation++;
    			break;
    			case 4:
    			attackRotation++;
    			break
    			case 3:
    			if(Misc.random(5) == 4){
    			attackRotation = 5;
    			}
    			attackRotation++;
    			break;
    			case 2:
    			attackRotation++;
    			break;
    			case 1:
    			attackRotation++;
    			break;
    			case 0:
    			attackRotation++;
    			break;
    			case 9:
    			attackRotation = 0;
    			break;
    		}
    }
    is wrong.
    would it not work? it is the same thing stripped down without attacks
    Reply With Quote  
     

  9. #8  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Quote Originally Posted by ventusX View Post
    would it not work? it is the same thing stripped down without attacks
    That right there is some nonsense. Why would you remove what you had previously anyways?
    Attached image
    Reply With Quote  
     

  10. #9  
    Registered Member
    Join Date
    Mar 2016
    Posts
    362
    Thanks given
    102
    Thanks received
    24
    Rep Power
    60
    Quote Originally Posted by Kris View Post
    That right there is some nonsense. Why would you remove what you had previously anyways?
    Because it contained lots of things not used in the tutorial, or the 'excess variables'

    Sent from my SM-G901F using Tapatalk
    Reply With Quote  
     

  11. #10  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Quote Originally Posted by ventusX View Post
    Because it contained lots of things not used in the tutorial, or the 'excess variables'

    Sent from my SM-G901F using Tapatalk
    Long story short, this is not a tutorial, nor is it really a snippet. Not entirely sure why you chose this topic to even demonstrate how to do it; the only way beginners would be able to learn from it is if there was full code of an example effect in front of them; they won't know what the hell to do with a switch case that contains odd looking repetitive code.
    Attached image
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. (easy)[PI] Simple fix for npcs
    By Eclipse in forum Help
    Replies: 2
    Last Post: 08-25-2012, 12:28 PM
  2. Attack emotes for npc's[PI]
    By rockarocka in forum Help
    Replies: 3
    Last Post: 01-31-2012, 12:53 AM
  3. [PI]Adding GFX For NPC's
    By Anonymous in forum Help
    Replies: 9
    Last Post: 05-25-2011, 04:44 AM
  4. [PI] Block emotes for NPC's [PI]
    By daone11 in forum Help
    Replies: 3
    Last Post: 08-18-2010, 12:47 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •