Thread: [Hyperion]How to make NPCs walk![Very easy]

Results 1 to 2 of 2
  1. #1 [Hyperion]How to make NPCs walk![Very easy] 
    Registered Member
    Join Date
    Aug 2014
    Posts
    2
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Although very basic, it works.

    Go to
    org.hyperion.rs2.event.impl
    And create the class NPCWalkEvent

    Code:
    package org.hyperion.rs2.event.impl;
    
    import org.hyperion.rs2.event.Event;
    import org.hyperion.rs2.model.Location;
    import org.hyperion.rs2.model.NPC;
    import org.hyperion.rs2.model.World;
    
    public class NPCWalkEvent extends Event {
    
    	public NPCWalkEvent(long delay) {
    		super(delay);
    	}
    
    	@Override
    	public void execute() {
    		for (NPC npc : World.getWorld().getNPCs()) {
    			int radius = npc.getWalkingRadius();
    			Location spawnLocation = npc.getSpawnLocation();
    			Location walkTo = Location.create((int) (spawnLocation.getX() + Math.random() * radius),
    					(int) (spawnLocation.getY() + Math.random() * radius), spawnLocation.getZ());
    			npc.getWalkingQueue().addStep(walkTo.getX(), walkTo.getY());
    		}
    	}
    
    }
    Go to the NPC class and add these methods:

    Code:
    /**
    	 * The maximum walking distance from spawn
    	 */
    	private int walkingRadius;
    
    	/**
    	 * The NPCs spawning location
    	 */
    	private Location spawnLocation;
    
    	public int getWalkingRadius() {
    		return walkingRadius;
    	}
    
    	public void setWalkingRadius(int radius) {
    		this.walkingRadius = radius;
    	}
    
    	public Location getSpawnLocation() {
    		return spawnLocation;
    	}
    
    	public void setSpawnLocation(Location spawnLocation) {
    		this.spawnLocation = spawnLocation;
    	}

    Go to World.java and search for
    Code:
    private void registerGlobalEvents()
    To this method add:
    Code:
    submit(new NPCWalkEvent(3000));
    The 3000 is the delay between the previous and next calculation. If you want the NPC to stand still longer you can increase the delay.

    Now to make this work, you will need to go to your NPC spawn loader and set the NPCs spawn location and NPC walking radius. I can show you how I did it, but you most likely handle spawns differently than I do, so this requires a little bit of hacking on your part.

    In my NPCLoader class
    Code:
    int x = Integer.parseInt(locationElement.getAttribute("X"));
    int y = Integer.parseInt(locationElement.getAttribute("Y"));
    int z = Integer.parseInt(locationElement.getAttribute("Z"));
    int radius = Integer.parseInt(walkElement.getAttribute("RADIUS"));
    Location spawnLocation = Location.create(x, y, z);
    npc.setLocation(spawnLocation);
    npc.setWalkingRadius(radius);
    I hope you enjoyed this tutorial and now have sexy walking NPCs.
    Goodbye
    Reply With Quote  
     

  2. #2  
    Registered Member 2nubs1cup's Avatar
    Join Date
    Jan 2013
    Posts
    972
    Thanks given
    77
    Thanks received
    90
    Rep Power
    15
    It's already easy to make npcs walk on Hyperion lol.
    Reply With Quote  
     


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. [508] How to make npcs walk! [508]
    By nitebomb1 in forum Configuration
    Replies: 12
    Last Post: 12-23-2010, 07:08 AM
  2. Replies: 9
    Last Post: 08-24-2010, 10:35 PM
  3. How to make npc walk on emulous
    By Infexis in forum Help
    Replies: 0
    Last Post: 03-28-2010, 03:44 PM
  4. Replies: 2
    Last Post: 10-24-2009, 01:17 PM
  5. How to make npc cant walk?
    By DDS-PKZ in forum Help
    Replies: 1
    Last Post: 09-22-2009, 08:36 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
  •