Thread: [PI]How to turn NPC into a different NPC [REP++]

Results 1 to 9 of 9
  1. #1 [PI]How to turn NPC into a different NPC [REP++] 
    Registered Member pk3r john's Avatar
    Join Date
    Apr 2009
    Posts
    877
    Thanks given
    16
    Thanks received
    30
    Rep Power
    63
    Ok so I'm doing sheep shearing.. and I need to know how to change a clothed sheep into a naked sheep.

    This is what I have under firstClickNPC in actionhandler:
    Code:
    			case 43:
    				npcType = 42;
    			break;
    But it doesn't do anything. whats the correct method for doing this? Will Rep++ for correct answer. thanks!

    EDIT:
    Tried this:
    Code:
    			case 43:
    				if(c.getItems().playerHasItem(1735, 1)) {
    				if(System.currentTimeMillis() - c.buryDelay > 2000) {
    				c.getItems().addItem(1737, 1);
    				c.sendMessage("You shear the sheep and get some wool.");
    				c.startAnimation(893);
    				c.buryDelay = System.currentTimeMillis();
    				int x = Server.npcHandler.npcs[].makeX;
    				int y = Server.npcHandler.npcs[].makeY;
    				Server.npcHandler.npcs.newNPC(42, x, y, 0, 1, 0, 0, 0, 0);
    			}
    		}
    Got this error:
    Code:
    src\server\model\players\ActionHandler.java:996: class expected
                                    int x = Server.npcHandler.npcs[].makeX;
                                                                     ^
    src\server\model\players\ActionHandler.java:997: class expected
                                    int y = Server.npcHandler.npcs[].makeY;
                                                                     ^
    2 errors
    Press any key to continue . . .
    Reply With Quote  
     

  2. #2  
    Fuckin PRO Derek's Avatar
    Join Date
    May 2008
    Posts
    1,257
    Thanks given
    38
    Thanks received
    86
    Rep Power
    67
    The only way I've seen this in RSPS is kqueen which is the npc dying and spawning another, but I don't think thats what your looking for. The easiest thing to do is put a timer on the sheep after sheering it until the wool grows back.
    Reply With Quote  
     

  3. #3  
    Registered Member pk3r john's Avatar
    Join Date
    Apr 2009
    Posts
    877
    Thanks given
    16
    Thanks received
    30
    Rep Power
    63
    Quote Originally Posted by Derek_ View Post
    The only way I've seen this in RSPS is kqueen which is the npc dying and spawning another, but I don't think thats what your looking for. The easiest thing to do is put a timer on the sheep after sheering it until the wool grows back.
    i'll try to look for the kalphite queen
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Mar 2011
    Posts
    4,062
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    Transformation mask in npc updating.
    Reply With Quote  
     

  5. #5  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    Code:
    public class Sheep extends NPC {
    
    	public Sheep(int slot, int type, Location spawn) {
    		super(slot, type, spawn);
    		super.maxHP = 0;
    	}
    
    
    	public void process() {
    		if (getType() == 42 && System.currentTimeMillis() - sheared > 60000) {
    			transform(43);
    		}
    		super.process();
    	}
    
    	public void handleShear(final Client c) {
    		if (!c.getItems().playerHasItem(1735)) {
    			c.sendMessage("I need shears to do that!");
    			return;
    		}
    		c.faceEntity(this);
    		if (getType() == 43) {
    			c.startAnimation(893);
    			World.getWorld().submit(new Tick(2) {
    				@Override
    				public void execute() {
    					if (c != null) {
    						if (Misc.random(9) == 1) {
    							WALK_TYPES walk = WALK_TYPES.getRandom();
    							if (walk != null)
    								getMove().walk(walk);
    							forceChat("BAAAAA!!");
    						} else {
    							c.getItems().addItem(1737, 1);
    							c.sendMessage("You shear the sheep and get some wool.");
    							forceChat("Baaaa!");
    							sheared = System.currentTimeMillis();
    							transform(42);
    						}
    						c.resetFacing();
    					}
    					this.stop();
    				}
    			});
    		} else {
    			c.sendMessage("This sheep is already sheered.");
    		}
    	}
    
    	long sheared;
    }
    doubt you can use that though p;

    ot; use the npc transform mask

    Code:
    public void transform(int Id) {
    		transformId = Id;
    		transformUpdateRequired = true;
    		updateRequired = true;
    	}
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Mar 2011
    Posts
    4,062
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    Quote Originally Posted by Harlan View Post
    Code:
    public class Sheep extends NPC {
    
    	public Sheep(int slot, int type, Location spawn) {
    		super(slot, type, spawn);
    		super.maxHP = 0;
    	}
    
    
    	public void process() {
    		if (getType() == 42 && System.currentTimeMillis() - sheared > 60000) {
    			transform(43);
    		}
    		super.process();
    	}
    
    	public void handleShear(final Client c) {
    		if (!c.getItems().playerHasItem(1735)) {
    			c.sendMessage("I need shears to do that!");
    			return;
    		}
    		c.faceEntity(this);
    		if (getType() == 43) {
    			c.startAnimation(893);
    			World.getWorld().submit(new Tick(2) {
    				@Override
    				public void execute() {
    					if (c != null) {
    						if (Misc.random(9) == 1) {
    							WALK_TYPES walk = WALK_TYPES.getRandom();
    							if (walk != null)
    								getMove().walk(walk);
    							forceChat("BAAAAA!!");
    						} else {
    							c.getItems().addItem(1737, 1);
    							c.sendMessage("You shear the sheep and get some wool.");
    							forceChat("Baaaa!");
    							sheared = System.currentTimeMillis();
    							transform(42);
    						}
    						c.resetFacing();
    					}
    					this.stop();
    				}
    			});
    		} else {
    			c.sendMessage("This sheep is already sheered.");
    		}
    	}
    
    	long sheared;
    }
    doubt you can use that though p;

    ot; use the npc transform mask

    Code:
    public void transform(int Id) {
    		transformId = Id;
    		transformUpdateRequired = true;
    		updateRequired = true;
    	}
    Also have to include the transformId in npc updating
    Reply With Quote  
     

  7. #7  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    Quote Originally Posted by iRageQuit2012 View Post
    Also have to include the transformId in npc updating
    ??
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Mar 2011
    Posts
    4,062
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    Quote Originally Posted by Harlan View Post
    ??
    The transform method won't do anything unless you include the transformId and everything in npc updating block

    like so:

    Code:
    public void appendTransformUpdate(Stream str) {
            str.writeWordBigEndianA(transformId);
        }
    then in npcupdatingblock

    Code:
    if (transformUpdateRequired)
    			appendTransformUpdate(str);
    Reply With Quote  
     

  9. #9  
    Father Of Lies


    Join Date
    May 2012
    Age
    26
    Posts
    1,216
    Thanks given
    267
    Thanks received
    289
    Rep Power
    242
    Say in itemonobject.java, how could we use this?
    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. Replies: 18
    Last Post: 01-03-2013, 01:09 AM
  2. [PI] Adding an NPC to turn Curses On
    By ParadoxPvP in forum Help
    Replies: 4
    Last Post: 08-24-2011, 10:47 PM
  3. turn npc
    By jaruanna in forum Help
    Replies: 8
    Last Post: 12-30-2010, 10:30 PM
  4. How to turn an NPC?
    By Ho H0 Ho in forum Help
    Replies: 3
    Last Post: 06-04-2010, 05:56 AM
  5. Turn player to NPC
    By Laxika in forum Tutorials
    Replies: 5
    Last Post: 05-13-2008, 08:34 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
  •