Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • SuperNativeZ: 2009SCAPE - Perfect Realistic Emulation. Play Runescape like it was in 2009. [link]
      February 18, 2020, 01:04:45 PM
    • SuperNativeZ: 2009SCAPE - Perfect Realistic Emulation. Play Runescape like it was in 2009. [link]
      February 18, 2020, 01:04:39 PM
    • SuperNativeZ: 2009SCAPE - Perfect Realistic Emulation. Play Runescape like it was in 2009. [link]
      February 18, 2020, 01:04:35 PM
    • ragnoroker: Join RuneGuild Today! BIG DROP PARTY IN 1 HOUR JOIN NOW - Newish Server 30+ Online all the time - Very Unique - Play now : [link]
      February 15, 2020, 04:16:38 PM
    • ragnoroker: Join RuneGuild Today! BIG DROP PARTY IN 1 HOUR JOIN NOW - Discord : [link]
      February 15, 2020, 04:15:41 PM
    • ragnoroker: Join RuneGuild Today! BIG DROP PARTY IN 1 HOUR JOIN NOW :) - [link]
      February 15, 2020, 04:14:50 PM
    • friendlyhelper: Meet up with old and new friends and explore what Runescape Classic could have been had development continued [link]
      February 15, 2020, 03:55:17 PM
    • friendlyhelper: Meet up with old and new friends and explore what Runescape Classic could have been had development continued [link]
      February 15, 2020, 03:49:34 PM
    • friendlyhelper: After well over 6 years of continuous runtime, RSCR still most actively developed RSC server  [link]
      February 15, 2020, 03:49:29 PM
    • SnowRSPS: Checkout Snowrsps.com - Snow317.org - Snowscape.net Open 24.7 [link] !Do not join Galaxy!
      February 15, 2020, 08:15:39 AM
    • SnowRSPS: Checkout Snowrsps.com - Snow317.org - Snowscape.net Open 24.7 [link] !Do not join Galaxy!
      February 15, 2020, 08:15:32 AM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS [link][link]
      February 14, 2020, 12:27:16 PM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS [link][link]
      February 14, 2020, 12:27:11 PM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS [link][link]
      February 14, 2020, 12:27:00 PM
    • ragnoroker: Looking for a new server? Join RuneGuild : [link] You won't be disappointed.
      February 14, 2020, 07:49:42 AM
    • ragnoroker: Looking for a new server? Join RuneGuild : [link] You won't be disappointed.
      February 14, 2020, 07:49:37 AM
    • ragnoroker: Looking for a new server? Join RuneGuild : [link] You won't be disappointed.
      February 14, 2020, 07:49:33 AM
    • Tonystark2830: https: //discord .gg /AHeVSMQ
      February 13, 2020, 11:35:21 AM
    • Tonystark2830:[link]
      February 13, 2020, 11:35:06 AM
    • Tonystark2830:[link] who ever has the most invites will be given money weekly! whats the catch? you must have over 15 invites for the week!  if you are tied with someone else at the end of the week you will both be awarded the same amount "no it will not be split"
      February 13, 2020, 11:34:42 AM

    Author Topic: Almost completely refactored NPC Update protocol (317)  (Read 1555 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineAmbokile

    • Member
    • ****
    • Posts: 3,009
    • Thanks: +0/-0
      • View Profile
    Almost completely refactored NPC Update protocol (317)
    « on: July 28, 2014, 08:57:17 AM »
    Here's an almost completely refactored update procol for NPCs. I've used other sources but I'm unsure of the authors. A lot of the work has come from myself.

    In the graphic updating (0x80) and the animation updating (0x10) there are some unnamed variables, I don't know what they do. If you know, please let me know.

    Code: Java
    1.     privatevoid updateNPCs(Stream stream)
    2.     {
    3.         for(int n =0; n < npcsAwaitingUpdatePointer; n++)
    4.         {
    5.             int npcId = npcsAwaitingUpdate[n];
    6.             NPC npc = npcArray[npcId];
    7.             int updateType = stream.getUnsignedByte();
    8.             if((updateType & 0x10)!=0)
    9.             {
    10.                 int animationId = stream.getUnsignedShort();
    11.                 if(animationId ==65535)
    12.                     animationId =-1;
    13.                 int animationDelay = stream.getUnsignedByte();
    14.                 if(animationId == npc.animation&& animationId !=-1)
    15.                 {
    16.                     int l2 = Animation.anims[animationId].anInt365;
    17.                     if(l2 ==1)
    18.                     {
    19.                         npc.anInt1527=0;
    20.                         npc.anInt1528=0;
    21.                         npc.animationDelay= animationDelay;
    22.                         npc.anInt1530=0;
    23.                     }
    24.                     if(l2 ==2)
    25.                         npc.anInt1530=0;
    26.                 }else
    27.                 if(animationId ==-1|| npc.animation==-1|| Animation.anims[animationId].anInt359>= Animation.anims[npc.animation].anInt359)
    28.                 {
    29.                     npc.animation= animationId;
    30.                     npc.anInt1527=0;
    31.                     npc.anInt1528=0;
    32.                     npc.animationDelay= animationDelay;
    33.                     npc.anInt1530=0;
    34.                     npc.anInt1542= npc.pathLength;
    35.                 }
    36.             }
    37.             if((updateType &8)!=0)
    38.             {
    39.                 int hitDamage = stream.getUnsignedByteA();
    40.                 int hitType = stream.getUnsignedByteC();
    41.                 npc.updateHitData(hitType, hitDamage, loopCycle);
    42.                 npc.loopCycleStatus= loopCycle +300;
    43.                 npc.currentHealth= stream.getUnsignedByteA();
    44.                 npc.maxHealth= stream.getUnsignedByte();
    45.             }
    46.             if((updateType & 0x80)!=0)
    47.             {
    48.                 npc.graphicId= stream.getUnsignedLEShort();
    49.                 int delay = stream.getInt();
    50.                 npc.graphicHeight= delay >>16;
    51.                 npc.graphicEndCycle= loopCycle +(delay & 0xffff);
    52.                 npc.currentAnimation=0;
    53.                 npc.anInt1522=0;
    54.                 if(npc.graphicEndCycle> loopCycle)
    55.                     npc.currentAnimation=-1;
    56.                 if(npc.graphicId==65535)
    57.                     npc.graphicId=-1;
    58.             }
    59.             if((updateType & 0x20)!=0)
    60.             {
    61.                 npc.interactingEntity= stream.getUnsignedLEShort();
    62.                 if(npc.interactingEntity==65535)
    63.                     npc.interactingEntity=-1;
    64.             }
    65.             if((updateType &1)!=0)
    66.             {
    67.                 npc.textSpoken= stream.getString();
    68.                 npc.textCycle=100;   
    69.             }
    70.             if((updateType & 0x40)!=0)
    71.             {
    72.                 int hitDamage = stream.getUnsignedByteC();
    73.                 int hitType = stream.getUnsignedByteS();
    74.                 npc.updateHitData(hitType, hitDamage, loopCycle);
    75.                 npc.loopCycleStatus= loopCycle +300;
    76.                 npc.currentHealth= stream.getUnsignedByteS();
    77.                 npc.maxHealth= stream.getUnsignedByteC();
    78.             }
    79.             if((updateType &2)!=0)
    80.             {
    81.                 npc.npcDefinition= EntityDef.forID(stream.getUnsignedShortA());
    82.                 npc.boundaryDimension= npc.npcDefinition.boundaryDimension;
    83.                 npc.degreesToTurn= npc.npcDefinition.degreesToTurn;
    84.                 npc.walkAnimationId= npc.npcDefinition.walkAnimationId;
    85.                 npc.turnAboutAnimationId= npc.npcDefinition.turnAboutAnimationId;
    86.                 npc.turnRightAnimationId= npc.npcDefinition.turnRightAnimationId;
    87.                 npc.turnLeftAnimationId= npc.npcDefinition.turnLeftAnimationId;
    88.                 npc.standAnimationId= npc.npcDefinition.standAnimationId;
    89.             }
    90.             if((updateType &4)!=0)
    91.             {
    92.                 npc.faceTowardX= stream.getUnsignedShort();
    93.                 npc.faceTowardY= stream.getUnsignedShort();
    94.             }
    95.         }
    96.     }
    « Last Edit: July 28, 2014, 01:50:33 PM by Ambokile »
    Runescape Gambling

    OfflineRuneAgent

    • wololo
    • Member
    • ****
    • *
    • *
    • Posts: 7,515
    • Thanks: +0/-0
      • View Profile
      • MITB FORUMS
    Re: Almost completely refactored NPC Update protocol (317)
    « Reply #1 on: July 28, 2014, 08:59:46 AM »
    why do you call it a mask?

    OfflineAmbokile

    • Member
    • ****
    • Posts: 3,009
    • Thanks: +0/-0
      • View Profile
    Re: Almost completely refactored NPC Update protocol (317)
    « Reply #2 on: July 28, 2014, 09:02:31 AM »
    why do you call it a mask?

    I've always thought that was the name for it and no one has told me otherwise :P What would be more suitable? "Opcode"?

    OfflineRuneAgent

    • wololo
    • Member
    • ****
    • *
    • *
    • Posts: 7,515
    • Thanks: +0/-0
      • View Profile
      • MITB FORUMS
    Re: Almost completely refactored NPC Update protocol (317)
    « Reply #3 on: July 28, 2014, 01:25:27 PM »
    I personally believe opcode would be a shitty description for the variable but maybe "updateType" would be more suitable

    OfflineAmbokile

    • Member
    • ****
    • Posts: 3,009
    • Thanks: +0/-0
      • View Profile
    Re: Almost completely refactored NPC Update protocol (317)
    « Reply #4 on: July 28, 2014, 01:50:45 PM »
    I personally believe opcode would be a shitty description for the variable but maybe "updateType" would be more suitable

    Done, thanks for the help :)

    OfflineGrievous Jr

    • First Time Poster
    • *
    • Posts: 2
    • Thanks: +0/-0
      • View Profile
    Re: Almost completely refactored NPC Update protocol (317)
    « Reply #5 on: August 04, 2014, 07:25:28 AM »
    Code: [Select]
    public static void update_actor_masks(Buffer b) {
    for (int i = 0; i < entity_count; i++) {
    Actor a = actors[entity_indices[i]];
    int mask = b.get_ubyte();

    if ((mask & 0x10) != 0) { // Animation
    int seq_index = b.get_le_ushort();

    if (seq_index == 65535) {
    seq_index = -1;
    }

    int delay = b.get_ubyte();

    if (seq_index == a.seq_index && seq_index != -1) {
    int type = Sequence.instance[seq_index].type;
    if (type == 1) {
    a.seq_frame = 0;
    a.seq_cycle = 0;
    a.seq_delay_cycle = delay;
    a.seq_reset_cycle = 0;
    }
    if (type == 2) {
    a.seq_reset_cycle = 0;
    }
    } else if (seq_index == -1 || a.seq_index == -1 || Sequence.instance[seq_index].priority >= Sequence.instance[a.seq_index].priority) {
    a.seq_index = seq_index;
    a.seq_frame = 0;
    a.seq_cycle = 0;
    a.seq_delay_cycle = delay;
    a.seq_reset_cycle = 0;
    a.still_path_position = a.path_position;
    }
    }

    if ((mask & 8) != 0) { // Hit
    int damage = b.get_ubyte_a();
    int type = b.get_ubyte_c();
    a.hit(type, damage, loop_cycle);
    a.combat_cycle = loop_cycle + 300;
    a.current_health = b.get_ubyte_a();
    a.max_health = b.get_ubyte();
    }

    if ((mask & 0x80) != 0) { // Graphics
    a.spotanim_index = b.get_ushort();

    int info = b.get_int();
    a.graphic_offset_y = info >> 16;
    a.spotanim_cycle_end = loop_cycle + (info & 0xFFFF);

    a.spotanim_frame = 0;
    a.spotanim_cycle = 0;

    if (a.spotanim_cycle_end > loop_cycle) {
    a.spotanim_frame = -1;
    }

    if (a.spotanim_index == 65535) {
    a.spotanim_index = -1;
    }
    }

    if ((mask & 0x20) != 0) { // Face Entity
    a.face_entity = b.get_ushort();

    if (a.face_entity == 65535) {
    a.face_entity = -1;
    }
    }

    if ((mask & 1) != 0) { // Forced Chat
    a.spoken_message = b.get_string();
    a.spoken_life = 100;
    }

    if ((mask & 0x40) != 0) { // Hit 2
    int damage = b.get_ubyte_c();
    int type = b.get_ubyte_s();
    a.hit(type, damage, loop_cycle);
    a.combat_cycle = loop_cycle + 300;
    a.current_health = b.get_ubyte_s();
    a.max_health = b.get_ubyte_c();
    }

    if ((mask & 2) != 0) { // Transform
    a.config = ActorConfig.get(b.get_le_ushort_a());
    a.size = a.config.has_options;
    a.turn_speed = a.config.turn_speed;
    a.walk_animation = a.config.move_seq;
    a.turn_180_animation = a.config.turn_180_seq;
    a.turn_r_animation = a.config.turn_r_seq;
    a.turn_l_animation = a.config.turn_l_seq;
    a.stand_animation = a.config.stand_sequence;
    }

    if ((mask & 4) != 0) { // Face Coordinate
    a.face_x = b.get_le_ushort();
    a.face_y = b.get_le_ushort();
    }
    }
    }

    More refactored

    Offlineimthenull

    • Member
    • ****
    • Posts: 2,511
    • Thanks: +1/-0
      • View Profile
    Re: Almost completely refactored NPC Update protocol (317)
    « Reply #6 on: August 06, 2014, 11:15:45 AM »
    wtf, npcsAwaitingUpdatePointer, thats really annoying

    why do you call it a mask?
    probably because it is a bit mask...?

     

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