Thread: REQ (876) Chicken walking animation

Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14
  1. #11  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    HAHAHA. I never thought I would ever actually one day link this snippet: https://www.rune-server.ee/runescape...nimations.html
    Project thread
    Reply With Quote  
     

  2. #12  
    Registered Member
    Join Date
    Sep 2013
    Posts
    242
    Thanks given
    14
    Thanks received
    7
    Rep Power
    11
    For people that want to do it le ugly way


    @Override
    public void processMovement() {
    super.processMovement();
    if (this.getName(). toLowerCase().contains("chicken") && getNextWalkDirection() != -1) {
    this.setNextAnimation(new Animation(24183));
    this.setNextForceMovement(new NewForceMovement(this, 1, null, 0,
    Utils.getFaceDirection(
    Utils.DIRECTION_DELTA_X[getNextWalkDirection()],
    Utils.DIRECTION_DELTA_Y[getNextWalkDirection()])));
    }
    }

    Just make a new file chicken.java or anything you want.



    Last edited by artizana; 11-25-2017 at 01:27 PM. Reason: .
    Reply With Quote  
     

  3. #13  
    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 artizana View Post
    For people that want to do it le ugly way


    @Override
    public void processMovement() {
    super.processMovement();
    if (this.getName(). toLowerCase().contains("chicken") && getNextWalkDirection() != -1) {
    this.setNextAnimation(new Animation(24183));
    this.setNextForceMovement(new NewForceMovement(this, 1, null, 0,
    Utils.getFaceDirection(
    Utils.DIRECTION_DELTA_X[getNextWalkDirection()],
    Utils.DIRECTION_DELTA_Y[getNextWalkDirection()])));
    }
    }

    Just make a new file chicken.java or anything you want.



    Ew. Don't do that.
    1) You don't need that name check there if you're already making a class dedicated to chickens.
    2) You're repeatedly creating new Animation and ForceMovement objects which really isn't good.
    3) That is a wrong and nasty way of doing so.

    Code:
    public final class Chicken extends NPC {
    
    public Chicken(final int id, final WorldTile tile, ...) {
    this.id = id;
    this.tile = tile;
    ... = ...;
    this.setRenderAnimation(CORRECT_CHICKEN_RENDER_ANIMATION);
    }
    
    }
    Of course this would force you to identify the render animation mask which on a 718 is 0x200 (all it does is send a short with the render animation id).
    Attached image
    Reply With Quote  
     

  4. Thankful user:


  5. #14  
    Registered Member
    Join Date
    Jul 2012
    Age
    25
    Posts
    122
    Thanks given
    16
    Thanks received
    21
    Rep Power
    15
    Quote Originally Posted by _Patrick_ View Post
    A class of two lines is better how? Make a method in NPC instead?
    Because it adds readability in the client. Most sources are written with bad habits. Separation is a very common programming principle when it comes to the design of the code. A good practice would be having an NPC-interface, every NPC implementing that interface.

    The alternative is having a general NPC-class and a CFG-file which contains all information needed for every NPC, the first alternative will however make it possible to change the behaviour of singular NPCs in a cleaner way.

    Edit: or make an abstract class and utilize template pattern.
    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

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. Replies: 2
    Last Post: 03-09-2017, 07:39 AM
  2. Replies: 7
    Last Post: 02-21-2017, 02:45 PM
  3. [REQ] Npc's Walking + stand anims.
    By Tony12 in forum Requests
    Replies: 1
    Last Post: 10-02-2011, 05:47 PM
  4. [REQ] Npc walking animations; REP++
    By R0cky 0wnz in forum Requests
    Replies: 1
    Last Post: 08-09-2009, 10:38 AM
  5. [req]New NPC Model Animations[req]
    By mast3r in forum Models
    Replies: 0
    Last Post: 04-22-2008, 08:16 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
  •