|
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:
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.
Good thread
super useful, thx kris
Extremely useful information. Collected the following list while going over my npc definitions to add an exclusion flag, which could be useful for others;
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)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
Wow thanks ! Very useful
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |