Thread: [718] Change NPC walking speed

Results 1 to 5 of 5
  1. #1 [718] Change NPC walking speed 
    Registered Member
    Join Date
    Jan 2015
    Posts
    195
    Thanks given
    137
    Thanks received
    28
    Rep Power
    27
    I need to change a certain NPC walking speed, like while its in combat, the speed with which it follows the player. I need it to run as fast as a player running, so how can I do this?
    Spoiler for Careful seizure:
    penis
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jan 2015
    Posts
    195
    Thanks given
    137
    Thanks received
    28
    Rep Power
    27
    Bump
    Spoiler for Careful seizure:
    penis
    Reply With Quote  
     

  3. #3  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    *NOTE* There's a probably a much more better way to do this, but this should work too.

    You should look in NPCCombat.java for this:

    Code:
    checkAll()
    Where it says addWalkSteps, that's the place where you're gonna add your exception.

    After that, you're gonna have to go in Entity.java(where addwalksteps is) and make a custom one and make the npc do a ForceMovement (if that's possible) and then a FT. So it should look like this in processNPC:

    Code:
    if (getId() == X) {
        addRunSteps(target.getX() + 1, npc.getY(), npc.getPlane());//One of the three
    }
    and a method like that in ForceMovement:

    Code:
    public void addRunSteps(int tox, int toy, int plane) {
        if(this instanceof NPC) {
        NPC npc = (NPC) this;
            //npc.setNextRender(X); No methods for npc I believe ;s
            int steps =  getForceMovementTime(tox, toy);
            WorldTile tile = new WorldTile(tox, toy, plane);
            npc.setNextForceMovement(new ForceMovement(tile, steps));
            WorldTasksManager.schedule(new WorldTask() {
    	    @Override
                public void run() {		
    	       npc.setNextWorldTile(tile);
    	    }
            }, steps);
        }
    }
    And then you make a getForceMovementTime that returns the time of the forcemovement depending on the distance : (tox^2 * toy^2) = distance^2.
    Project thread
    Reply With Quote  
     

  4. Thankful user:


  5. #4  
    Registered Member
    Join Date
    Jan 2015
    Posts
    195
    Thanks given
    137
    Thanks received
    28
    Rep Power
    27
    Quote Originally Posted by clem585 View Post
    *NOTE* There's a probably a much more better way to do this, but this should work too.

    You should look in NPCCombat.java for this:

    Code:
    checkAll()
    Where it says addWalkSteps, that's the place where you're gonna add your exception.

    After that, you're gonna have to go in Entity.java(where addwalksteps is) and make a custom one and make the npc do a ForceMovement (if that's possible) and then a FT. So it should look like this in processNPC:

    Code:
    if (getId() == X) {
        addRunSteps(target.getX() + 1, npc.getY(), npc.getPlane());//One of the three
    }
    and a method like that in ForceMovement:

    Code:
    public void addRunSteps(int tox, int toy, int plane) {
        if(this instanceof NPC) {
        NPC npc = (NPC) this;
            //npc.setNextRender(X); No methods for npc I believe ;s
            int steps =  getForceMovementTime(tox, toy);
            WorldTile tile = new WorldTile(tox, toy, plane);
            npc.setNextForceMovement(new ForceMovement(tile, steps));
            WorldTasksManager.schedule(new WorldTask() {
    	    @Override
                public void run() {		
    	       npc.setNextWorldTile(tile);
    	    }
            }, steps);
        }
    }
    And then you make a getForceMovementTime that returns the time of the forcemovement depending on the distance : (tox^2 * toy^2) = distance^2.
    Thank you very much for the reply, although I can't figure out where on that method you posted is a "running speed" I get what you said about making a method that returns the time needed for the movement from point A to B but where would I put that into?

    Right now I managed to make the NPC run but I need to speed up the walking animation so it looks more natural, if this is possible, it'd be quicker than making a new variable speed method for the NPC movement. If not I'll just try to use what you proposed first. Thanks again!
    Spoiler for Careful seizure:
    penis
    Reply With Quote  
     

  6. #5  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by PvM Chapi View Post
    Thank you very much for the reply, although I can't figure out where on that method you posted is a "running speed" I get what you said about making a method that returns the time needed for the movement from point A to B but where would I put that into?

    Right now I managed to make the NPC run but I need to speed up the walking animation so it looks more natural, if this is possible, it'd be quicker than making a new variable speed method for the NPC movement. If not I'll just try to use what you proposed first. Thanks again!
    I don't know how you did it but maybe this could help you:

    Code:
    public Animation(int id, int speed) {
        this(id, id, id, id, speed);
    }
    Project thread
    Reply With Quote  
     

  7. Thankful user:



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. 718 Changing NPC drops
    By Old Oak in forum Help
    Replies: 5
    Last Post: 06-07-2014, 05:55 PM
  2. [718] Changing NPC Names
    By CamperScape in forum Tutorials
    Replies: 27
    Last Post: 05-25-2014, 08:40 AM
  3. Replies: 5
    Last Post: 03-14-2014, 09:54 AM
  4. [718] Change npc health
    By Lord in forum Help
    Replies: 2
    Last Post: 10-04-2012, 04:33 PM
  5. Replies: 6
    Last Post: 05-29-2010, 09:16 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •