Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • DeathsChaos9: Well damn, long time no see m8
      May 27, 2018, 10:37:06 PM
    • usman555: i remembered out of nowhere and came to check how mopar was going
      May 27, 2018, 08:34:39 PM
    • usman555: remember azaruth, deathz
      May 27, 2018, 08:34:24 PM
    • usman555: hey
      May 27, 2018, 08:33:56 PM
    • Vain_: buying gf
      May 27, 2018, 01:53:12 PM
    • charmie: WILKO MY MAIN MAIN!
      May 26, 2018, 08:26:59 PM
    • DeathsChaos9::|
      May 26, 2018, 01:27:54 AM
    • Saltyspade10: Okay I won't be back
      May 24, 2018, 07:12:40 AM
    • [email protected]: im buying an ad banner from graham the owner need to get in contact
      May 23, 2018, 08:57:06 PM
    • [email protected]: any mods on
      May 23, 2018, 08:56:49 PM
    • kepoly: 11 years ago, damn
      May 23, 2018, 01:38:39 PM
    • B50: Sever error what happen
      May 22, 2018, 08:23:40 PM
    • The Soul: 10 years later
      May 21, 2018, 05:23:10 PM
    • The Soul: wow people are still here?
      May 21, 2018, 05:19:27 PM
    • Wilkooo: and apologies to the OG forum guys on behalf of that fudgewit dr house that pretty much killed this entire domain
      May 21, 2018, 04:14:28 PM
    • Wilkooo: shoutout to all those that played back in the beginning, all new people that hang around now seem to be pretty braindead
      May 21, 2018, 04:13:54 PM
    • Wilkooo: born sep 2016 - died whenever pink eggs resigned
      May 21, 2018, 04:11:29 PM
    • Wilkooo: Rip moparscape rsps
      May 21, 2018, 04:11:10 PM
    • puta loca: or what section can i ask this
      May 21, 2018, 05:45:08 AM
    • puta loca: does someoen has platinum ps v2 files?
      May 21, 2018, 05:44:59 AM

    Author Topic: [SOLVED]  (Read 535 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineMiraak

    • First Time Poster
    • *
    • Posts: 3
    • Thanks: +0/-0
      • View Profile
    [SOLVED]
    « on: July 22, 2015, 01:16:13 AM »
    FIXED



    So I wrote this method to replace NPC's directly.

    Code: [Select]
    public static void replaceNpc(int slot, int npcType, int x, int y, int heightLevel,
    int WalkingType, int HP, int maxHit, int attack, int defence) {
    NPC newNPC = new NPC(slot, npcType);
    newNPC.absX = x;
    newNPC.absY = y;
    newNPC.makeX = x;
    newNPC.makeY = y;
    newNPC.heightLevel = heightLevel;
    newNPC.walkingType = WalkingType;
    newNPC.HP = HP;
    newNPC.MaxHP = HP;
    newNPC.maxHit = maxHit;
    newNPC.attack = attack;
    newNPC.defence = defence;
    npcs[slot] = newNPC;
    npcs[slot].updateRequired = true;
    }

    So I'm directly replacing the NPC data and forcing an update. However, the transition is not smooth, the sheep first disappears and the other one appears later.

     What gives? Can anyone help with this?

    -----------------EDIT:Progress---------------------------------------------------------------
    I've written a new approach for changing sheep

    Code: [Select]
    public static void replaceSheep(int i) {
    //
    NPC newNPC = new NPC(i, 42);
    newNPC.makeX = npcs[i].makeX;
    newNPC.makeY = npcs[i].makeY;
    newNPC.heightLevel = npcs[i].heightLevel;
    newNPC.walkingType = npcs[i].walkingType;
    newNPC.HP = npcs[i].HP;
    newNPC.MaxHP = npcs[i].HP;
    newNPC.maxHit = npcs[i].maxHit;
    newNPC.attack = npcs[i].attack;
    newNPC.defence = npcs[i].defence;
    npcs[i] = newNPC;
    npcs[i].updateRequired = true;
    }

    But now, instead of using
    Code: [Select]
    npcs[i].isDead = true through the death method to trigger the change (thats probably what caused the 'lag'), I directly call this in firstclick of clicknpc.java

    Code: [Select]
    switch(c.npcType){
    case 43:
    NPCHandler.replaceSheep(id);
    c.sendMessage("You get some wool.");
    break;
    case 42:
    c.sendMessage("You're not supposed to be firstclicking this.");
    break;
    }

    This is sucessful in the fact that all of the npc information (id,position etc) changes as expected, but the sheep I see remains the original one. I have debugs to make sure the Id changes, also I won't get wool if I click the 'transformed' sheep, but the problem is - the sheep doesn't change visually, I still get the same click options too.
    tl;dr: Sheep doesn't update visually after changing? Any ideas?
    « Last Edit: July 22, 2015, 02:57:45 AM by Miraak »
    RS2Ad banner

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: [SOLVED]
    « Reply #1 on: July 22, 2015, 12:53:10 PM »
    Way too much work for making your npcs change.
    All you have to do is change the npc id and then rebuild the npc list for the players.

    Code: Java
    1.                 npcs[i].npcType= newId;
    2.                 npcs[i].updateRequired=true;
    3.                 npcs[i].animUpdateRequired=true;
    4.                 for(Player p : PlayerHandler.players){
    5.                         if(p !=null){
    6.                                 p.RebuildNPCList=true;
    7.                         }
    8.                 }
    That is about all you honestly need. There's no reason to delete an npc and then create a new one.
    RS2Ad banner

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal