Sly 2:Entity pooling

From SlyMods
Jump to navigation Jump to search
Entity pooling
Game Mechanic
GameSly 2: Band of Thieves

Entity pooling, sometimes called proxy pooling, is the mechanic by which the game spawns in a certain number of entities during a level load and re-uses them to create the illusion that there are many more than there actually are.

Overview

In Sly 2: Band of Thieves, each entity FK$x has an array of instances of that entity, along with the size of the array. We call the array the “pool” for that entity and its size the “entity cap” for that entity.

If you follow the pointer from the FK$x to the pool array, you will find N pointers to instances of that entity, where N is the entity cap. Each instance of an entity is called a “proxy” of that entity.

Raising the entity cap

You can raise the cap for an entity and the game will initialize more proxies to fill in the pool. However, be aware that doing so will shift the memory addresses of any entities what are initialized after that. You must do this before the phase of the level load where it initializes all of the proxies.

Swapping entity pointers

If you edit the proxy pool for an entity to replace one of the pointers with a pointer to another entity, the game will spawn that entity instead of the original entity. For example, if you replace one of the pointers to a boar guard in Paris with a pointer to Dimitri, then the game will spawn Dmitri on patrol on the streets of Paris.

Typically you must do this during a level load, but there are some exceptions such as swapping an entity with the music box powerup. Also, certain types of entities will crash the game if swapped, such as attempting to swap guards with scenery.

The side effect of this is that it may cause issues when the game tries to spawn in the entity from its original pool. For example, if you swap Dmitri with a boar guard, then the Follow Dimitri job will softlock after you ring the bell.