This dll allows you to modify collision of players and vehicles.
It can be used for challenge or racing servers, to prevent players interfering with each other.
- Create a blank win32 project in Visual Studio.
- Place the files from PlayerCollisionToggle in the project.
- Add the files to the project in Solution Explorer and click Build.
- Install BlocklandLoader.
- Place the compiled dll in Blockland/modules/.
- Start Blockland.
You can set collision between vehicles using the global setVehicleCollision(bool enabled)
method.
You can set collision between players using the global setPlayerCollision(bool enabled)
method.
You can move a player to a second collision layer by changing it's typemask:
%player.setType((%player.getType() | $TypeMasks::PlayerObjectTypeHidden) & ~$TypeMasks::PlayerObjectTypeNormal);
And change it back like this:
%player.setType((%player.getType() | $TypeMasks::PlayerObjectTypeNormal) & ~$TypeMasks::PlayerObjectTypeHidden);
This allows other players to walk through it.
By default, searches only return players in the normal collision layer.
You can change this by using the $TypeMasks::PlayerObjectTypeHidden
and $TypeMasks::PlayerObjectTypeAll
masks for individual searches.
If you need to modify the default behavior, you can do something like this: $TypeMasks::PlayerObjectType = $TypeMasks::PlayerObjectTypeAll;
You will need to install MoveHandler for some of these to work. For unknown reasons MoveHandler crashes your server if you spawn a hole bot.
$Physics::VehicleCollisionMask &= ~$TypeMasks::PlayerObjectTypeAll;
$Physics::VehicleCollisionMask |= $TypeMasks::PlayerObjectTypeAll;
function onPlayerProcessTick(%player, %move)
{
if(%player.getType() & $TypeMasks::PlayerObjectTypeHidden)
{
$Physics::PlayerMoveMask &= ~$TypeMasks::PlayerObjectTypeNormal;
$Physics::PlayerContactMaskServer &= ~$TypeMasks::PlayerObjectTypeNormal;
}
else
{
$Physics::PlayerMoveMask |= $TypeMasks::PlayerObjectTypeNormal;
$Physics::PlayerContactMaskServer |= $TypeMasks::PlayerObjectTypeNormal;
}
}
function onPlayerProcessTick(%player, %move)
{
if(%player.getType() & $TypeMasks::PlayerObjectTypeHidden)
{
$Physics::PlayerMoveMask &= ~$TypeMasks::PlayerObjectTypeNormal;
$Physics::PlayerContactMaskServer &= ~$TypeMasks::PlayerObjectTypeNormal;
$Physics::PlayerMoveMask |= $TypeMasks::PlayerObjectTypeHidden;
$Physics::PlayerContactMaskServer |= $TypeMasks::PlayerObjectTypeHidden;
}
else
{
$Physics::PlayerMoveMask &= ~$TypeMasks::PlayerObjectTypeHidden;
$Physics::PlayerContactMaskServer &= ~$TypeMasks::PlayerObjectTypeHidden;
$Physics::PlayerMoveMask |= $TypeMasks::PlayerObjectTypeNormal;
$Physics::PlayerContactMaskServer |= $TypeMasks::PlayerObjectTypeNormal;
}
}
Allow all players to collide with each other, but let players in the second layer walk through static shapes:
$Physics::PlayerMoveMask |= $TypeMasks::PlayerObjectTypeAll;
$Physics::PlayerContactMaskServer |= $TypeMasks::PlayerObjectTypeAll;
function onPlayerProcessTick(%player, %move)
{
if(%player.getType() & $TypeMasks::PlayerObjectTypeHidden)
{
$Physics::PlayerMoveMask &= ~$TypeMasks::StaticShapeObjectType;
$Physics::PlayerContactMaskServer &= ~$TypeMasks::StaticShapeObjectType;
}
else
{
$Physics::PlayerMoveMask |= $TypeMasks::StaticShapeObjectType;
$Physics::PlayerContactMaskServer |= $TypeMasks::StaticShapeObjectType;
}
}