Thread: Entity blocking and stacking mechanic

Results 1 to 8 of 8
  1. #1 Entity blocking and stacking mechanic 
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    What is this thread about?
    Most NPCs found in RuneScape will not walk on-top of other NPCs or players, however it is possible to force them to do so anyways. This thread will explain in-depth how the mechanic behind that works.

    EDIT: An improved version of this document can be found on osrs-docs.com
    Contact me for access.

    Conditions
    This mechanic applies to most NPCs, however bosses and certain exceptions will be excluded from it. They will neither lay the flags, remove them nor check for them. I'll provide a rough list of creatures below which ignore the mechanic. This information cannot be found in the cache, or on the wikia for that matter.

    Note: This list is not confirmed, these are just the creatures I've assumed ignore the mechanic. Some of them, such as the godwars one, are confirmed though. There may be more creatures that could fit into this list. Creatures who are in an area which only consists of themselves do not need to be excluded from this mechanic, which is why you won't see some bosses here.
    Spoiler for Excluded NPCs:

    • All three dagannoth kings
    • Grotesque guardians(Dusk & Dawn)
    • Skotizo
    • Smoke devil
    • Mage Arena II NPCs
    • All CoX NPCs
    • All followers(pets essentially)
    • Godwars generals and minions
    • Barrows wights
    • Jal-Nib (Inferno)
    • Ravager, Spinner & Splatter(Pest Control)
    • Animated armour (Warriors' guild)
    • Hunter creatures
    • The Mimic
    • Blast furnace ore(on the conveyor belt)
    • Kalphite queen
    • Wilderness bosses



    Collision flags
    The mechanic works by using otherwise unused clipping flags. You will need to figure out which bits are unused by any flags yourself. Do not use a flag that's already occupied, as entities can move, and upon moving the previously-occupied tile will get unflagged. You don't want to lose information on the map-provided clippings.

    Gorillas group label: Bearded monkey guard(Ape Atoll), Brawler.


    • NPC-occupied flag.
      Added by:
      - All NPCs except for:
      • Excluded NPCs above.
      • Gorillas group.


      Validated by:
      - All NPCs except for:
      • Gorillas group.


      Removed by:
      - Players.
      - All NPCs except for:
      • Excluded NPCs above.
      • Gorillas group.


    • Player-occupied flag.
      Added and removed by:
      - Players.

      Validated by:
      - All NPCs except for:
      • Gorillas group.
      • Sulphur clouds.
      • Certain exceptions from the "Excluded NPCs above", such as pets. Godwars generals and their minions will ignore the player flags though.


    • Block-everything flag.
      (Unconfirmed, this may be two individual flags, or may also be a single combined flag - there is no way of knowing as all the scenarios in RuneScape have them both enabled at once!)

      Added and removed by:
      - Gorillas group.

      Validated by:
      - All NPCs.
      - Players.
      - Projectiles(Neither you nor NPCs can shoot arrows or send spells through a tile which has this flag set!)

    The player-occupied and NPC-occupied flags are near identical in essence, and you may actually merge them together if you're not using OSRS. There is only one scenario I know of in OSRS where you can actually determine that NPCs and Players have separated flags. This is in the sulphur mine in Zeah. An efficient mechanic used there is tagging a level two spider by splashing on it, and using said spider to block the sulphur clouds from reaching you in the north-western part of the area, as seen here(the spider is slightly visible by the player’s head on the picture, blocking the northern side - the southern side is blocked by the area itself, as that is unwalkable in the necessary 2x2 block). The level two spider will block the clouds, however players do not. Without the spider there blocking access from the northern side, the sulphur cloud would be able to walk on top of the player and start dealing damage to them.



    The Mechanic
    When a creature(player, NPC who isn't excluded) spawns into the world, the tiles upon which they stand will all have their respective occupied flag added. When the creature despawns(post-death or log out), all the tiles which they occupied will have their respective occupied flag removed. The flag will be removed regardless of whether or not another NPC or player stands underneath, this part is important to remember as this is the only way to get creature-stacking working correctly.
    During movement, right before you reposition the creature, you must remove the flags underneath the creature. After removing the flags beneath the creature, you reposition it, and add the flags back for the tiles which the creature now occupies. Note that, when running, you are supposed to process each tile individually. So, when players run, they move two tiles. You must repeat this process for each of the two tiles. It is important to do it for all tiles and not just skip to the end position as this is essential for the stacking mechanic.



    The Stacking Mechanic
    If you followed what I mentioned above correctly, you will have the stacking mechanic working automatically. Here is a video which shows how the mechanic is performed:
    Spoiler for Stacking mechanic video(Skip to 1:21):



    Explanation of the mechanic:
    After tagging all the creatures as shown in the video, the creatures will then be blocked behind one another due to the flags. The player will stand in a position which allows them to cross a tile without making the creature closest to them move their position(as that re-sets the flag on the ground which is not ideal). Upon running over the tile on which the NPC closest to you stands, you will remove the NPC-occupied flag on that tile, allowing another NPC to walk on that tile. This process is repeated until all the NPCs stack on one tile.



    Pathfinder
    The intelligent pathfinder will not use the three aforementioned flags anywhere, meaning that regardless of if the tile is blocked by the entity flags, the intelligent pathfinder will determine a path straight through it. Only later during the path validation will you be prevented from walking on the tile, if such a flag is set. After spending 10 minutes trying to find a video which demonstrates it, I give up. Every video just skips right past this mechanic.


    Basic Code Example
    The unclip and clip methods that you end up with should roughly look like this(I will only provide the player-perspective clip and unclip methods):


    The 'location' variable refers to the player's current location. The PLAYER_OCCUPIED and NPC_OCCUPIED are the flags I mentioned earlier in the thread.
    You can manage the NPC versions yourself, the only difference in that is the flags which each NPC sets. As for validation, you'll need to include that yourself in whatever method validates your steps. You can just bitwise-or the flag into the existing flags which you already validate(e.g. block-object and whatnot).


    If something remains unclear, ask below.
    Reply With Quote  
     


  2. #2  
    Developer


    Join Date
    Aug 2012
    Posts
    2,493
    Thanks given
    180
    Thanks received
    1,732
    Rep Power
    2487
    Good thread
    Reply With Quote  
     

  3. #3  
    🎶 As you're falling down 🎶


    uint32_t's Avatar
    Join Date
    Feb 2015
    Posts
    1,396
    Thanks given
    6,177
    Thanks received
    776
    Rep Power
    5000
    Nice contribution, contributor.
    Quote Originally Posted by Idiot Bird View Post
    Quote Originally Posted by Velocity View Post
    lol np mate looks like the community brought ur rep down to ur IQ
    Not too sure about that, it's at 0 . It would have to go minus to even be remotely close to his IQ.
    Reply With Quote  
     

  4. #4  
    08-13, SpawnScape Owner

    jet kai's Avatar
    Join Date
    Dec 2009
    Age
    28
    Posts
    870
    Thanks given
    630
    Thanks received
    957
    Rep Power
    5000
    thx kristine
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Extreme Donator


    Join Date
    Jun 2018
    Posts
    58
    Thanks given
    100
    Thanks received
    44
    Rep Power
    1323
    super useful, thx kris
    Attached image
    Reply With Quote  
     

  7. #6  
    ⚔️ Battle614 - Superiority ⚔️

    Battle614's Avatar
    Join Date
    Aug 2020
    Posts
    243
    Thanks given
    72
    Thanks received
    472
    Rep Power
    803
    Awesome info! GJ

    Attached image
    Reply With Quote  
     

  8. #7  
    Super Donator

    Chivvon's Avatar
    Join Date
    May 2016
    Posts
    487
    Thanks given
    69
    Thanks received
    142
    Rep Power
    285
    Extremely useful information. Collected the following list while going over my npc definitions to add an exclusion flag, which could be useful for others;
    Code:
    6496, 6498 6497, 7286, 498, 499, 318, 495, 497, 964, 2055, 2130, 2131, 2132, 5536, 5537, 5561, 5884, 5892, 8009, 6628, 6629, 6630, 6631, 6633, 6634, 6635, 6636, 6637, 6638, 6639, 6640, 6642, 7520, 425, 8025, 6715, 6717, 6719, 6718, 6720, 7451, 7334, 7335, 7336, 7337-7350, 2215, 2216, 2217, 2218, 3129, 3130, 3131, 3132, 3162, 3163, 3164, 3165, 2205, 2206, 2207, 2208, 1672, 1673,1673 1674, 1675, 1676, 1677, 6500, 6501, 6504 6609 6611 6612, 2054, 6618,6619, 6615, 5531, 5532, 5533, 5548, 5549, 5550, 5551, 5552, 1505, 2910, 2911, 2912, 1852, 1853, 3420, 3421, 3422, 3134, 1635 – 1644, 5553, 5554, 5555, 5556
    Missing: Grotesque guardians(Dusk & Dawn), Skotizo, Mage Arena II NPCs, Jal-Nib (Inferno), Ravager, Spinner & Splatter(Pest Control), Animated armour (Warriors' guild), The Mimic, Blast furnace ore(on the conveyor belt)
    Reply With Quote  
     

  9. #8  
    Donator

    Mythic Dream's Avatar
    Join Date
    Jun 2021
    Posts
    145
    Thanks given
    17
    Thanks received
    145
    Rep Power
    800
    Wow thanks ! Very useful
    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: 21
    Last Post: 08-03-2013, 01:55 AM
  2. Replies: 4
    Last Post: 04-13-2013, 09:57 PM
  3. C staff block and attack anim
    By Orel in forum Requests
    Replies: 4
    Last Post: 08-27-2012, 02:24 PM
  4. Replies: 4
    Last Post: 11-24-2011, 11:04 PM
  5. Replies: 14
    Last Post: 08-23-2010, 12: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
  •