Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • King Bosnia: Any recommendations to private servers?
      October 18, 2018, 04:47:35 PM
    • FightMexoxo: oi i have the files if anyone whats em
      October 18, 2018, 12:44:42 AM
    • The Wanderer: Whoops
      October 15, 2018, 12:56:18 AM
    • The Wanderer: Making own operating system
      October 15, 2018, 12:56:11 AM
    • Travas: no
      October 07, 2018, 04:03:36 PM
    • Saltyspade10: Server still up and running?
      October 05, 2018, 07:13:41 PM
    • Wesam: Can someone upload moparscape.jar?
      October 05, 2018, 11:43:43 AM
    • Ligoe: yo
      September 30, 2018, 12:48:15 PM
    • Ligoe: how come i can't login the game
      September 30, 2018, 12:48:03 PM
    • fuzzout: Anybody here with experience in using Luna source? I'm looking to develop something, but can't seem to get any of my clients to work with it...
      September 26, 2018, 10:47:27 AM
    • `Discardedx2`: ?
      September 21, 2018, 12:24:09 PM
    • Pookey71: ARE YOU HERE TO RECEIVE MY LIMP PENIS!?
      September 20, 2018, 11:55:24 PM
    • Pookey71: THIS IS DEMOCRACY MANIFESTO
      September 20, 2018, 11:55:07 PM
    • Vasi28: Гранд
      September 03, 2018, 07:06:22 PM
    • Rash: test
      August 30, 2018, 09:09:18 PM
    • Guruu:[link]
      August 30, 2018, 12:04:45 AM
    • Guruu: am i allowed to post links shoutbox?
      August 30, 2018, 12:03:46 AM
    • drubrkletern:[link] feedback wanted
      August 28, 2018, 03:55:17 PM
    • bugz000: Anyone got a link for the old ass silab client and cache.zip? from mopar 3.2 era :) 317
      August 25, 2018, 12:48:15 AM
    • cholland2015: Does anyone know where I can download the old moparscape client/server?
      August 24, 2018, 02:30:51 PM

    Author Topic: [SOLVED]  (Read 575 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 »
    Runescape Gambling

    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.
    Runescape Gambling

     

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