Thread: NPC not reverting back. Help please.

Results 1 to 3 of 3
  1. #1 NPC not reverting back. Help please. 
    Registered Member
    Join Date
    May 2014
    Posts
    23
    Thanks given
    0
    Thanks received
    2
    Rep Power
    11
    I am currently trying to get the NPC's in Canifis to change to werewolf's, and then once defeated change back to the original char models. This is proving to be more difficult that I first imagined. So far here is a snippet of what I have.

    Code:
                  if(npc.getId() == 6028){
    			    npc.setNextAnimation(new Animation(6554));
    			    WorldTasksManager.schedule(new WorldTask() {
    			        @Override
    				 public void run() {
    				     npc.transformIntoNPC(6012);
    				}
    			});
                            }
    This also does exactly the same thing

    Code:
                  if(npc.getId() == 6028){
                                npc.transformIntoNPC(6012);
                            }
    The problem I am having is when the NPC dies, It will respawn as the transformed NPC (6012). What do I need to do to make it transform back on death?

    Any help is greatly appreciated!

    UPDATE

    I made the code work better but its still not working correctly.

    Code:
    public class YuriTransform extends CombatScript {
    
        @Override
        public Object[] getKeys() {
            return new Object[]{6028};
        }
    
        @Override
        public int attack(final NPC npc, final Entity target) {
            NPCCombatDefinitions defs = npc.getCombatDefinitions();
    
            if (npc.getId() == 6028) {
                npc.setNextAnimation(new Animation(6554));
                WorldTasksManager.schedule(new WorldTask() {
                    @Override
                    public void run() {
                        npc.transformIntoNPC(+6012);
                    }
                }, 1, 2);
            }
            return defs.getAttackDelay();
        }
    }
    Reply With Quote  
     

  2. #2  
    add me on rs

    Join Date
    Aug 2017
    Posts
    350
    Thanks given
    238
    Thanks received
    115
    Rep Power
    141
    basically when it dies, its starting the respawn task with the npc you've changed into, so create an exception for werewolfs to start the respawn task with the normal id where you'd handle npc deaths
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    May 2014
    Posts
    23
    Thanks given
    0
    Thanks received
    2
    Rep Power
    11
    Yes, that would work i suppose but i have like 25 diffrent charecters with 25 diffrent werewolf models, if i set it in that file would it not just convert all the werewolfs on death to the same char model? Also all of them would still have their name set as werewolf, obviosly you can specify the name and what to change the model back into manually but that is alot of repetive code. I was hoping there was a solution that would make them revert back on death in the class file im working in. I can do this with a timer but that is sloppy. for example the rock crabs. They go from item to npc. It seems like going from npc to npc is more diffucult for some reason.

    Finally...

    Its still needs a bit of fine tuning. but I got it to work. Any input on making it better I'm all eyes....

    Code:
    public class YuriTransform extends CombatScript {
    
        @Override
        public Object[] getKeys() {
            return new Object[]{6028};
        }
    
        @Override
        public int attack(final NPC npc, final Entity target) {
            if (npc.getId() == 6028) {
                npc.setNextAnimation(new Animation(6554));
                WorldTasksManager.schedule(new WorldTask() {
                    @Override
                    public void run() {
                        npc.transformIntoNPC(+6012);
                        if (npc.isUnderCombat() == false) {
                            end();
                        }
                    }
                    private void end() {
                        npc.transformIntoNPC(6028);
                        npc.checkAgressivity();   
                    }
                }, 0, 1);
            }
            return 0;
        }
    }
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 02-05-2017, 09:52 PM
  2. Replies: 5
    Last Post: 08-04-2010, 10:21 AM
  3. Not urgent but help please
    By McGahan in forum Help
    Replies: 2
    Last Post: 02-18-2010, 04:10 PM
  4. Replies: 2
    Last Post: 01-31-2010, 10:06 AM
  5. Replies: 3
    Last Post: 01-31-2010, 10:04 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
  •