Thread: Proper NPC Teleport on Death

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1 Proper NPC Teleport on Death 
    Tetris
    Guest
    Hello Rune-Server members. Have any of you ever tried making an NPC teleport you when it dies and failed? Have you ever used a tutorial that caused the teleportation of players that did not deal the most damage to the monster? Well, I have a fix for you guys.

    Difficulty: 1/10
    Required Skills: How to read, how to copy, how to paste.
    Purpose: To inform (Not to give you a bunch of codes and tell you exactly where to put them and claim this is a tutorial).
    Base Tested On: Bulby's Strife (Should work for most 317's as long as they are Winterlove based)

    Step One:

    Open up your NpcHandler (NpcHandler.java)
    Why?: This needs to be opened up so you can perform an editing task.

    Step Two:

    Locate your monster drops/effects on death in your NpcHandler.
    How: Search for "Item2.random"

    You should come up with something that looks like the following example...

    Code:
    if(npcs[NPCID].npcType == 59) {
    ItemHandler.addItem(Item2.randomSpider(), npcs[NPCID].absX, npcs[NPCID].absY, 1, GetNpcKiller(NPCID), false);
    }
    Step Three:

    Keep in mind that the npcType is the npc that you want to drop items or teleport you upon death, etc.

    So, copy the above code, paste it under the last bracket of something that looks like the above code, and change the npcType from "59" to the ID of the NPC that you want to make teleport you to a location.

    Now, delete "ItemHandler.addItem(Item2.randomSpider(), npcs[NPCID].absX, npcs[NPCID].absY, 1, GetNpcKiller(NPCID), false);"

    Step Four:

    The reason that this was deleted was because it was responsible for telling the server to drop the items for the method, randomSpider() in a different class known as item2 (item2.java is the editable file that is then compiled to modify the class), and this is not needed for the purpose of teleporting a player when the NPC dies.

    So, now that you understand that, this is were it may get confusing.

    In the space that was created upon deleting the above code, add the following:

    Code:
    client tele = (client) server.playerHandler.players[GetNpcKiller(NPCID)];
    Now, let me explain this...

    This is saying that the sever will use the client class to act on the player that dealt the most damage to the monster after it died, and it will recognize any variables in the client class as long as they are preceded by tele. in the npcHandler.

    Difference from most tutorials: Most tutorials use something along the lines of...

    Code:
    int Player = npcs[NPCID].StartKilling;
    client ppl = (client) server.playerHandler.players[Player];
    This tells the server that the variable "ppl" only applies to whoever last started attacking the monster as opposed to who dealt the most damae to kill the monster, and this causes problems if a person is attacking a monster and someone else comes along and hits it once because that person is the one who gets teleported.

    Step 5:

    Now you should have something similar to:

    Code:
    if(npcs[NPCID].npcType == 59) {
    client tele = (client) server.playerHandler.players[GetNpcKiller(NPCID)];
    }
    Now, understand that the client class uses "TeleportToX and TeleportToY for Winterlove bases to teleport players to different locations, so naturally, we must add those into this code.

    Due the fact that we enabled this specific monster death in npcHandler to recognize all variables in the client class as long as they are preceded by "tele.", we can now add the following:

    Code:
    tele.teleportToX = ####;
    tele.teleportToY = ####;
    Note: You must change the ####'s to the X and Y coordinates that you wish the monster to teleport the player to on death.

    So, your final code should look something like this example:

    Code:
    if(npcs[NPCID].npcType == 59) {
    client tele = (client) server.playerHandler.players[GetNpcKiller(NPCID)];
    tele.teleportToX = 3564;
    tele.teleportToY = 3288;
    }
    Step 6:

    Save the npcHandler class, compile your server files, and run your server.

    Congratulate yourself on the successful completion of this tutorial.

    Post questions or errors that you receive on this thread.

    _________________________________

    Other Uses:

    Slayer skills (use the NPC death to coordinate with the client class in order to add experience and decrease monster counts, etc.)

    Barrows (allow the brothers to teleport the proper player to a different brother upon death)

    There are plenty of other uses for this accurate NPC death teleport.



    ~ Tetris
    Reply With Quote  
     

  2. #2  
    Tetris
    Guest
    No comments?
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Dec 2008
    Posts
    12
    Thanks given
    162
    Thanks received
    62
    Rep Power
    0
    well casue its common sense but great tut
    Reply With Quote  
     

  4. #4  
    Xenon
    Guest
    Agreed ^.
    Reply With Quote  
     

  5. #5  
    Registered Member
    The Myth's Avatar
    Join Date
    Oct 2008
    Posts
    751
    Thanks given
    5
    Thanks received
    9
    Rep Power
    105
    Quote Originally Posted by Tetris
    Open up your NpcHandler (NpcHandler.java)
    Why?: This needs to be opened up so you can perform an editing task.
    Rofl we're not retarded, and Ive never had this problem so i just scimmed, probaly because your using winterlove
    Funny how when one person talks to an invisible man and commits acts in their name it's called schizophrenia, but when 1.166 billion people do it simultaneously it's called religion.

    Reply With Quote  
     

  6. #6  
    Tetris
    Guest
    You'd be surprised at who is retarded and who isn't.
    Reply With Quote  
     

  7. #7  
    Ahrims
    Guest
    great tut.
    repped

    even though i have no use for this it is very well made.
    Reply With Quote  
     

  8. #8  
    Registered Member

    Join Date
    Aug 2008
    Posts
    273
    Thanks given
    0
    Thanks received
    0
    Rep Power
    103
    this is just spoon feeding...no offense but pure logic, for this case i can just make a tut on changing the name of the server:

    First off go to client file (client.java) and double click it.
    why? because you need to double click to open and here you edit.

    Find the name of the source you downloaded by going to Edit that is at the right of File and click it and click on Find then type in the name of the source and click Next, and change it, then save it by going File> Save and then close it by clicking on the Big X button on the right top of your screen, then double click on the .bat file that is titled Compiler or Compile and then let it compile then click on the big X and then click run....

    thats a tut like yours....common sense but yet you run out of ideas and come back to the basics instead of thinking outside the box, and adding some kewl stuff or making new interfaces, waste of potential.

    No Offense
    Hola
    Reply With Quote  
     

  9. #9  
    Registered Member Tx-Sec's Avatar
    Join Date
    Jan 2008
    Age
    30
    Posts
    520
    Thanks given
    34
    Thanks received
    15
    Rep Power
    68
    Very nice but i already know this.
    Reply With Quote  
     

  10. #10  
    xAcid Tripx
    Guest
    You guys are being assholes, he actually thought of making a tutorial for the NOOBS at coding. Not the retarded but the people who just started making their own server and would like to add npc teleport after death. I mean the "editing task" part was un needed but it's still a good tutorial.

    I would Rep++ if I could but I can't and thanks for this tutorial I can use it in my new mini game
    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •