Giter VIP home page Giter VIP logo

playercollisiontoggle's Introduction

Player Collision Toggle

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.

Compiling

  1. Create a blank win32 project in Visual Studio.
  2. Place the files from PlayerCollisionToggle in the project.
  3. Add the files to the project in Solution Explorer and click Build.

Installation

  1. Install BlocklandLoader.
  2. Place the compiled dll in Blockland/modules/.
  3. Start Blockland.

Usage

Disabling collision for all vehicles

You can set collision between vehicles using the global setVehicleCollision(bool enabled) method.

Disabling collision for all players

You can set collision between players using the global setPlayerCollision(bool enabled) method.

Disabling collision for specific players

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.

Raycasts and box searches

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;

Modifying collision behavior (examples)

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.

Prevent vehicles from colliding with any players:

$Physics::VehicleCollisionMask &= ~$TypeMasks::PlayerObjectTypeAll;

Allow vehicles to collide with all players:

$Physics::VehicleCollisionMask |= $TypeMasks::PlayerObjectTypeAll;

Allow players in the second layer to walk through players in the first layer:

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;
	}
}

Players collide with other players in the same layer, and pass through players in the other:

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;
	}
}

playercollisiontoggle's People

Contributors

qoh avatar zeblote avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.